Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8b9a3bb
Updated to curl 8.13
COM8 May 1, 2025
8e61e25
Fixed errno not being 0 before port parsing
COM8 May 1, 2025
a69fabc
Getting a local unused port
COM8 May 1, 2025
d28eb57
Installing libpsl in the CI since it is a curl requirement
COM8 May 1, 2025
a2724b2
Fixed usage of CPR_USE_SYSTEM_CURL in CI runs
COM8 May 1, 2025
1ed12dc
Libpsl fixes for macOS and Windows
COM8 May 1, 2025
55b9e5a
Added missing testUtils.cpp for SSL tests
COM8 May 1, 2025
ca73a97
Switched over to "ubuntu:latest" and "ubuntu:rolling" instead of spec…
COM8 May 4, 2025
1caefb9
Installing libpsl-devel for the clang-tidy run
COM8 May 4, 2025
0a25082
Switched cppcheck builds to fedora from ubuntu
COM8 May 4, 2025
ca07b27
CI file cleanup
COM8 May 4, 2025
27cf0e4
Fixed missing libpsl-dev for deb builds
COM8 May 4, 2025
f6a73b6
Fixed CI
COM8 May 4, 2025
1b7e401
libpsl build support
COM8 May 15, 2025
a3743c3
Fixed get random port on Windows
COM8 May 15, 2025
80caf61
libpsl CI fixes
COM8 May 15, 2025
eadfca4
CI install libunistring-dev on ubuntu
COM8 May 15, 2025
cf55eb7
Fixed libpsl on non windows systems
COM8 May 15, 2025
d419f1d
Installing meson in the windows CI
COM8 May 15, 2025
0caf98f
Added missing meson CI runs
COM8 May 29, 2025
c7d1864
Replaced deprecated FetchContent_Populate with FetchContent_MakeAvail…
COM8 May 29, 2025
5910cad
Using system libpsl on macOS inside the CI
COM8 May 29, 2025
ebeb2d5
Using system curl and psl for deb builds
COM8 May 29, 2025
2b57983
Potential Windows compilation fix
COM8 Jun 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ jobs:
steps:
- name: "Checkout"
uses: actions/checkout@v3
with:
submodules: true
path: cpr

# Install packages necessary for building libcpr and package
- name: "Update package list"
run: sudo apt update
- name: "Install cpr dependencies"
run: sudo apt install -y libssl-dev libcurl4-openssl-dev
run: sudo apt install -y libssl-dev libcurl4-openssl-dev libpsl-dev
- name: "Install building tools"
run: sudo apt install -y cmake debmake devscripts debhelper
# Set version number
Expand All @@ -34,7 +30,7 @@ jobs:
run: |
mkdir -p cpr/build
pushd cpr/build
cmake .. -DCPR_BUILD_VERSION_OUTPUT_ONLY=ON
cmake .. -DCPR_BUILD_VERSION_OUTPUT_ONLY=ON -DCPR_USE_SYSTEM_LIB_PSL=ON -DCPR_USE_SYSTEM_CURL=ON
echo "RELEASE_VERSION=$(cat version.txt)" >> $GITHUB_ENV
popd
rm -rf cpr/build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
run: echo "NuGet version will be '${{ env.RELEASE_VERSION }}'"
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Setup NuGet.exe
uses: nuget/setup-nuget@v2
- name: Install meson
run: pip install meson
- name: "[Release_x86] Build & Install"
env:
CMAKE_GENERATOR: "Visual Studio 16 2019"
Expand Down
52 changes: 34 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
ubuntu-clang-openssl:
strategy:
matrix:
container: ["ubuntu:20.04", "ubuntu:24.04", "ubuntu:latest"]
container: ["ubuntu:latest", "ubuntu:rolling"]
systemCurl: [ON, OFF]
buildType: [Debug, Release]
runs-on: ubuntu-latest
Expand All @@ -21,7 +21,7 @@ jobs:
- name: Update package list
run: apt update
- name: Install Dependencies
run: apt install -y git libssl-dev cmake build-essential clang libcurl4-openssl-dev
run: apt install -y git libssl-dev cmake build-essential clang libcurl4-openssl-dev libpsl-dev meson libunistring-dev
env:
DEBIAN_FRONTEND: noninteractive
- name: Setup cmake
Expand All @@ -35,7 +35,7 @@ jobs:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: ON
CPR_FORCE_OPENSSL_BACKEND: ON
USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
CPR_USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
Expand All @@ -49,7 +49,7 @@ jobs:
ubuntu-gcc-openssl:
strategy:
matrix:
container: ["ubuntu:20.04", "ubuntu:24.04", "ubuntu:latest"]
container: ["ubuntu:latest", "ubuntu:rolling"]
systemCurl: [ON, OFF]
buildType: [Debug, Release]
runs-on: ubuntu-latest
Expand All @@ -58,7 +58,7 @@ jobs:
- name: Update package list
run: apt update
- name: Install Dependencies
run: apt install -y git libssl-dev cmake build-essential libcurl4-openssl-dev
run: apt install -y git libssl-dev cmake build-essential libcurl4-openssl-dev libpsl-dev meson libunistring-dev
env:
DEBIAN_FRONTEND: noninteractive
- name: Setup cmake
Expand All @@ -72,7 +72,7 @@ jobs:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: ON
CPR_FORCE_OPENSSL_BACKEND: ON
USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
CPR_USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
Expand All @@ -89,7 +89,7 @@ jobs:
- name: Update package list
run: sudo apt update
- name: Install Dependencies
run: sudo apt install -y git libssl-dev libmbedtls-dev cmake build-essential
run: sudo apt install -y git libssl-dev libmbedtls-dev cmake build-essential libpsl-dev meson libunistring-dev
env:
DEBIAN_FRONTEND: noninteractive
- name: Setup cmake
Expand All @@ -114,24 +114,21 @@ jobs:
ctest-options: ${{ env.CTEST_OPTIONS }}

fedora-clang-openssl:
strategy:
matrix:
container: ["fedora:latest"]
runs-on: ubuntu-latest
container: ${{ matrix.container }}
container: "fedora:latest"
steps:
- name: Update package list
run: dnf update -y
- name: Install Dependencies
run: dnf install -y gcc clang git gcc gdb make openssl-devel libcurl-devel cmake
run: dnf install -y gcc clang git gcc gdb make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson
- name: Checkout
uses: actions/checkout@v3
- name: "Build & Test"
env:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: ON
CPR_FORCE_OPENSSL_BACKEND: ON
USE_SYSTEM_CURL: OFF
CPR_USE_SYSTEM_CURL: OFF
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
Expand All @@ -145,24 +142,23 @@ jobs:
fedora-gcc-openssl:
strategy:
matrix:
container: ["fedora:latest"]
systemCurl: [ON, OFF]
buildType: [Debug, Release]
runs-on: ubuntu-latest
container: ${{ matrix.container }}
container: "fedora:latest"
steps:
- name: Update package list
run: dnf update -y
- name: Install Dependencies
run: dnf install -y gcc clang git gcc gdb make openssl-devel libcurl-devel cmake
run: dnf install -y gcc clang git gcc gdb make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson
- name: Checkout
uses: actions/checkout@v3
- name: "Build & Test"
env:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: ON
CPR_FORCE_OPENSSL_BACKEND: ON
USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
CPR_USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
Expand All @@ -183,7 +179,7 @@ jobs:
- name: Update package list
run: dnf update -y
- name: Install Dependencies
run: dnf install -y gcc clang git gcc gdb make openssl-devel libasan libubsan liblsan libtsan cmake
run: dnf install -y gcc clang git gcc gdb make openssl-devel libasan libubsan liblsan libtsan cmake libpsl-devel libunistring-devel meson
- name: Checkout
uses: actions/checkout@v3
- name: "Build & Test"
Expand All @@ -206,13 +202,17 @@ jobs:
buildType: [Debug, Release]
runs-on: windows-latest
steps:
- uses: actions/setup-python@v1
- name: Install meson
run: pip install meson
- name: Checkout
uses: actions/checkout@v3
- name: "Build & Test"
env:
CMAKE_GENERATOR: "Visual Studio 17 2022"
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: OFF
CURL_USE_LIBPSL: OFF
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
Expand All @@ -224,6 +224,9 @@ jobs:
windows-msvc-openssl:
runs-on: windows-latest
steps:
- uses: actions/setup-python@v1
- name: Install meson
run: pip install meson
- name: Install OpenSSL
run: choco install openssl -y
- name: Checkout
Expand All @@ -234,6 +237,7 @@ jobs:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: ON
CPR_FORCE_OPENSSL_BACKEND: ON
CURL_USE_LIBPSL: OFF
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
Expand All @@ -248,12 +252,15 @@ jobs:
buildType: [Debug, Release]
runs-on: macos-latest
steps:
- name: Install libpsl
run: brew install libpsl
- name: Checkout
uses: actions/checkout@v3
- name: "Build & Test"
env:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: OFF
CPR_USE_SYSTEM_LIB_PSL: ON
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
Expand All @@ -267,13 +274,16 @@ jobs:
macos-clang-darwinssl:
runs-on: macos-latest
steps:
- name: Install libpsl
run: brew install libpsl
- name: Checkout
uses: actions/checkout@v3
- name: "Build & Test"
env:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: OFF
CPR_FORCE_DARWINSSL_BACKEND: ON
CPR_USE_SYSTEM_LIB_PSL: ON
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
Expand All @@ -289,13 +299,16 @@ jobs:
steps:
- name: Install OpenSSL
run: brew install openssl
- name: Install libpsl
run: brew install libpsl
- name: Checkout
uses: actions/checkout@v3
- name: "Build & Test"
env:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: ON
CPR_FORCE_OPENSSL_BACKEND: ON
CPR_USE_SYSTEM_LIB_PSL: ON
OPENSSL_ROOT_DIR: "${{ env.MACOS_OPENSSL_ROOT_DIR }}"
OPENSSL_LIBRARIES: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
LDFLAGS: "-L${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
Expand All @@ -318,6 +331,8 @@ jobs:
run: brew install boost
- name: Install OpenSSL
run: brew install openssl
- name: Install libpsl
run: brew install libpsl
- name: Checkout
uses: actions/checkout@v3
- name: "Build & Test"
Expand All @@ -326,6 +341,7 @@ jobs:
CPR_BUILD_TESTS_SSL: ON
CPR_FORCE_OPENSSL_BACKEND: ON
CPR_USE_BOOST_FILESYSTEM: ON
CPR_USE_SYSTEM_LIB_PSL: ON
OPENSSL_ROOT_DIR: "${{ env.MACOS_OPENSSL_ROOT_DIR }}"
OPENSSL_LIBRARIES: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
LDFLAGS: "-L${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Update package list
run: sudo dnf update -y
- name: Install dependencies
run: sudo dnf install -y openssl-devel cmake git gcc clang ninja-build
run: sudo dnf install -y openssl-devel cmake git gcc clang ninja-build libpsl-devel meson
- name: Install clang-tidy
run: sudo dnf install -y clang-tools-extra
- name: Checkout
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ on: [push, workflow_dispatch, pull_request] # Trigger for every push as well as
jobs:
cppcheck:
runs-on: ubuntu-latest
container: "fedora:latest" # Use fedora for an up to date version of cppcheck
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Update package list
run: sudo apt update
- name: Install cppcheck
run: sudo apt install cppcheck
run: dnf update -y
- name: Install Dependencies
run: dnf install -y gcc clang git gcc gdb make openssl-devel cmake libpsl-devel cppcheck meson
- name: "[Release g++] Build"
env:
CPR_ENABLE_CPPCHECK: ON
Expand Down
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ cpr_option(CPR_CURL_NOSIGNAL "Set to ON to disable use of signals in libcurl." O
cpr_option(CURL_VERBOSE_LOGGING "Curl verbose logging during building curl" OFF)
cpr_option(CPR_USE_SYSTEM_GTEST "If ON, this project will look in the system paths for an installed gtest library. If none is found it will use the built-in one." OFF)
cpr_option(CPR_USE_SYSTEM_CURL "If enabled we will use the curl lib already installed on this system." OFF)
cpr_option(CPR_USE_SYSTEM_LIB_PSL "Since curl 8.13 it depends on libpsl. If enabled we will use the psl lib already installed on this system. Else meson is required as build dependency." ${CPR_USE_SYSTEM_CURL})
cpr_option(CPR_ENABLE_CURL_HTTP_ONLY "If enabled we will only use the HTTP/HTTPS protocols from CURL. If disabled, all the CURL protocols are enabled. This is useful if your project uses libcurl and you need support for other CURL features e.g. sending emails." ON)
cpr_option(CPR_ENABLE_SSL "Enables or disables the SSL backend. Required to perform HTTPS requests." ON)
cpr_option(CPR_FORCE_OPENSSL_BACKEND "Force to use the OpenSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
Expand Down Expand Up @@ -294,10 +295,14 @@ else()
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
FetchContent_Declare(curl
URL https://github.com/curl/curl/releases/download/curl-8_10_1/curl-8.10.1.tar.xz
URL_HASH SHA256=73a4b0e99596a09fa5924a4fb7e4b995a85fda0d18a2c02ab9cf134bebce04ee # the file hash for curl-8.10.1.tar.xz
USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress

# Since curl 8.13, curl depends on lib psl
if(NOT ${CPR_USE_SYSTEM_LIB_PSL})
include(libpsl)
endif()

FetchContent_Declare(curl URL https://github.com/curl/curl/releases/download/curl-8_13_0/curl-8.13.0.tar.xz
URL_HASH SHA256=4a093979a3c2d02de2fbc00549a32771007f2e78032c6faa5ecd2f7a9e152025) # the file hash for curl-8.13.0.tar.xz
FetchContent_MakeAvailable(curl)

restore_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)
Expand Down Expand Up @@ -377,7 +382,7 @@ if(CPR_BUILD_TESTS)
USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress
# We can not use FetchContent_MakeAvailable, since we need to patch mongoose to use CMake
if (NOT mongoose_POPULATED)
FetchContent_POPULATE(mongoose)
FetchContent_MakeAvailable(mongoose)

file(INSTALL cmake/mongoose.CMakeLists.txt DESTINATION ${mongoose_SOURCE_DIR})
file(RENAME ${mongoose_SOURCE_DIR}/mongoose.CMakeLists.txt ${mongoose_SOURCE_DIR}/CMakeLists.txt)
Expand Down
59 changes: 59 additions & 0 deletions cmake/libpsl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Builds libpsl which is especially necessary on Windows since there it is not available via e.g. a package manager.

include(ExternalProject)
find_program(MESON_PATH meson)

if(MESON_PATH STREQUAL "MESON_PATH-NOTFOUND")
message(FATAL_ERROR "meson not found. Please make sure you have meson installed on your system (https://mesonbuild.com/Getting-meson.html). Meson is required for building libpsl for curl on Windows.")
return()
endif()

FetchContent_Declare(libpsl_src GIT_REPOSITORY https://github.com/rockdaboot/libpsl.git
GIT_TAG 0.21.5)
FetchContent_MakeAvailable(libpsl_src) # sets libpsl_src_SOURCE_DIR / _BINARY_DIR

set(LIBPSL_SOURCE_DIR "${libpsl_src_SOURCE_DIR}")
set(LIBPSL_BUILD_DIR "${libpsl_src_BINARY_DIR}")
set(LIBPSL_INSTALL_DIR "${CMAKE_BINARY_DIR}/libpsl_src-install")
file(MAKE_DIRECTORY "${LIBPSL_BUILD_DIR}")

# Meson configure
# We only care about static libraries of psl. In case you need a dynamic version, feel free to add support for it.
message(STATUS "Configuring libpsl...")
execute_process(COMMAND "${MESON_PATH}" setup
"${LIBPSL_BUILD_DIR}"
"${LIBPSL_SOURCE_DIR}"
-Dtests=false
-Ddocs=false
--buildtype=release
--prefix "${LIBPSL_INSTALL_DIR}"
--default-library=static
RESULT_VARIABLE MESON_SETUP_RC)
if(MESON_SETUP_RC)
message(FATAL_ERROR "Meson setup for libpsl failed!")
endif()

# Meson build
message(STATUS "Building libpsl...")
execute_process(COMMAND "${MESON_PATH}" compile -C "${LIBPSL_BUILD_DIR}"
RESULT_VARIABLE MESON_COMPILE_RC
)
if(MESON_COMPILE_RC)
message(FATAL_ERROR "Meson compile for libpsl failed!")
endif()

# Meson install
message(STATUS "Installing libpsl...")
execute_process(COMMAND "${MESON_PATH}" install -C "${LIBPSL_BUILD_DIR}"
RESULT_VARIABLE MESON_INSTALL_RC)
if(MESON_INSTALL_RC)
message(FATAL_ERROR "Meson install for libpsl failed!")
endif()

list(APPEND CMAKE_LIBRARY_PATH "${LIBPSL_INSTALL_DIR}/lib64")
list(APPEND CMAKE_LIBRARY_PATH "${LIBPSL_INSTALL_DIR}/lib")
list(APPEND CMAKE_INCLUDE_PATH "${LIBPSL_INSTALL_DIR}/include")

# Workaround for Windows compilation.
# Ref: https://github.com/microsoft/vcpkg/pull/38847/files#diff-922fe829582a7e5acf5b0c35181daa63064fc12a2c889c5d89a19e5e02113f1bL44
add_compile_definitions(PSL_STATIC=1)
Loading
Loading