Skip to content

Commit bb8fbf7

Browse files
authored
Merge pull request #1217 from libcpr/feature/curl8.13_update
WIP CURL 8.13 Support
2 parents 2a393ff + 2b57983 commit bb8fbf7

File tree

12 files changed

+268
-81
lines changed

12 files changed

+268
-81
lines changed

.github/workflows/build-deb.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ jobs:
1414
steps:
1515
- name: "Checkout"
1616
uses: actions/checkout@v3
17-
with:
18-
submodules: true
19-
path: cpr
20-
2117
# Install packages necessary for building libcpr and package
2218
- name: "Update package list"
2319
run: sudo apt update
2420
- name: "Install cpr dependencies"
25-
run: sudo apt install -y libssl-dev libcurl4-openssl-dev
21+
run: sudo apt install -y libssl-dev libcurl4-openssl-dev libpsl-dev
2622
- name: "Install building tools"
2723
run: sudo apt install -y cmake debmake devscripts debhelper
2824
# Set version number
@@ -34,7 +30,7 @@ jobs:
3430
run: |
3531
mkdir -p cpr/build
3632
pushd cpr/build
37-
cmake .. -DCPR_BUILD_VERSION_OUTPUT_ONLY=ON
33+
cmake .. -DCPR_BUILD_VERSION_OUTPUT_ONLY=ON -DCPR_USE_SYSTEM_LIB_PSL=ON -DCPR_USE_SYSTEM_CURL=ON
3834
echo "RELEASE_VERSION=$(cat version.txt)" >> $GITHUB_ENV
3935
popd
4036
rm -rf cpr/build

.github/workflows/build-nuget.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
run: echo "NuGet version will be '${{ env.RELEASE_VERSION }}'"
2727
- name: Checkout
2828
uses: actions/checkout@v3
29-
with:
30-
submodules: true
3129
- name: Setup NuGet.exe
3230
uses: nuget/setup-nuget@v2
31+
- name: Install meson
32+
run: pip install meson
3333
- name: "[Release_x86] Build & Install"
3434
env:
3535
CMAKE_GENERATOR: "Visual Studio 16 2019"

.github/workflows/ci.yml

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
ubuntu-clang-openssl:
1313
strategy:
1414
matrix:
15-
container: ["ubuntu:20.04", "ubuntu:24.04", "ubuntu:latest"]
15+
container: ["ubuntu:latest", "ubuntu:rolling"]
1616
systemCurl: [ON, OFF]
1717
buildType: [Debug, Release]
1818
runs-on: ubuntu-latest
@@ -21,7 +21,7 @@ jobs:
2121
- name: Update package list
2222
run: apt update
2323
- name: Install Dependencies
24-
run: apt install -y git libssl-dev cmake build-essential clang libcurl4-openssl-dev
24+
run: apt install -y git libssl-dev cmake build-essential clang libcurl4-openssl-dev libpsl-dev meson libunistring-dev
2525
env:
2626
DEBIAN_FRONTEND: noninteractive
2727
- name: Setup cmake
@@ -35,7 +35,7 @@ jobs:
3535
CPR_BUILD_TESTS: ON
3636
CPR_BUILD_TESTS_SSL: ON
3737
CPR_FORCE_OPENSSL_BACKEND: ON
38-
USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
38+
CPR_USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
3939
uses: ashutoshvarma/action-cmake-build@master
4040
with:
4141
build-dir: ${{ github.workspace }}/build
@@ -49,7 +49,7 @@ jobs:
4949
ubuntu-gcc-openssl:
5050
strategy:
5151
matrix:
52-
container: ["ubuntu:20.04", "ubuntu:24.04", "ubuntu:latest"]
52+
container: ["ubuntu:latest", "ubuntu:rolling"]
5353
systemCurl: [ON, OFF]
5454
buildType: [Debug, Release]
5555
runs-on: ubuntu-latest
@@ -58,7 +58,7 @@ jobs:
5858
- name: Update package list
5959
run: apt update
6060
- name: Install Dependencies
61-
run: apt install -y git libssl-dev cmake build-essential libcurl4-openssl-dev
61+
run: apt install -y git libssl-dev cmake build-essential libcurl4-openssl-dev libpsl-dev meson libunistring-dev
6262
env:
6363
DEBIAN_FRONTEND: noninteractive
6464
- name: Setup cmake
@@ -72,7 +72,7 @@ jobs:
7272
CPR_BUILD_TESTS: ON
7373
CPR_BUILD_TESTS_SSL: ON
7474
CPR_FORCE_OPENSSL_BACKEND: ON
75-
USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
75+
CPR_USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
7676
uses: ashutoshvarma/action-cmake-build@master
7777
with:
7878
build-dir: ${{ github.workspace }}/build
@@ -89,7 +89,7 @@ jobs:
8989
- name: Update package list
9090
run: sudo apt update
9191
- name: Install Dependencies
92-
run: sudo apt install -y git libssl-dev libmbedtls-dev cmake build-essential
92+
run: sudo apt install -y git libssl-dev libmbedtls-dev cmake build-essential libpsl-dev meson libunistring-dev
9393
env:
9494
DEBIAN_FRONTEND: noninteractive
9595
- name: Setup cmake
@@ -114,24 +114,21 @@ jobs:
114114
ctest-options: ${{ env.CTEST_OPTIONS }}
115115

116116
fedora-clang-openssl:
117-
strategy:
118-
matrix:
119-
container: ["fedora:latest"]
120117
runs-on: ubuntu-latest
121-
container: ${{ matrix.container }}
118+
container: "fedora:latest"
122119
steps:
123120
- name: Update package list
124121
run: dnf update -y
125122
- name: Install Dependencies
126-
run: dnf install -y gcc clang git gcc gdb make openssl-devel libcurl-devel cmake
123+
run: dnf install -y gcc clang git gcc gdb make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson
127124
- name: Checkout
128125
uses: actions/checkout@v3
129126
- name: "Build & Test"
130127
env:
131128
CPR_BUILD_TESTS: ON
132129
CPR_BUILD_TESTS_SSL: ON
133130
CPR_FORCE_OPENSSL_BACKEND: ON
134-
USE_SYSTEM_CURL: OFF
131+
CPR_USE_SYSTEM_CURL: OFF
135132
uses: ashutoshvarma/action-cmake-build@master
136133
with:
137134
build-dir: ${{ github.workspace }}/build
@@ -145,24 +142,23 @@ jobs:
145142
fedora-gcc-openssl:
146143
strategy:
147144
matrix:
148-
container: ["fedora:latest"]
149145
systemCurl: [ON, OFF]
150146
buildType: [Debug, Release]
151147
runs-on: ubuntu-latest
152-
container: ${{ matrix.container }}
148+
container: "fedora:latest"
153149
steps:
154150
- name: Update package list
155151
run: dnf update -y
156152
- name: Install Dependencies
157-
run: dnf install -y gcc clang git gcc gdb make openssl-devel libcurl-devel cmake
153+
run: dnf install -y gcc clang git gcc gdb make openssl-devel libcurl-devel cmake libpsl-devel libunistring-devel meson
158154
- name: Checkout
159155
uses: actions/checkout@v3
160156
- name: "Build & Test"
161157
env:
162158
CPR_BUILD_TESTS: ON
163159
CPR_BUILD_TESTS_SSL: ON
164160
CPR_FORCE_OPENSSL_BACKEND: ON
165-
USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
161+
CPR_USE_SYSTEM_CURL: ${{ matrix.systemCurl }}
166162
uses: ashutoshvarma/action-cmake-build@master
167163
with:
168164
build-dir: ${{ github.workspace }}/build
@@ -183,7 +179,7 @@ jobs:
183179
- name: Update package list
184180
run: dnf update -y
185181
- name: Install Dependencies
186-
run: dnf install -y gcc clang git gcc gdb make openssl-devel libasan libubsan liblsan libtsan cmake
182+
run: dnf install -y gcc clang git gcc gdb make openssl-devel libasan libubsan liblsan libtsan cmake libpsl-devel libunistring-devel meson
187183
- name: Checkout
188184
uses: actions/checkout@v3
189185
- name: "Build & Test"
@@ -206,13 +202,17 @@ jobs:
206202
buildType: [Debug, Release]
207203
runs-on: windows-latest
208204
steps:
205+
- uses: actions/setup-python@v1
206+
- name: Install meson
207+
run: pip install meson
209208
- name: Checkout
210209
uses: actions/checkout@v3
211210
- name: "Build & Test"
212211
env:
213212
CMAKE_GENERATOR: "Visual Studio 17 2022"
214213
CPR_BUILD_TESTS: ON
215214
CPR_BUILD_TESTS_SSL: OFF
215+
CURL_USE_LIBPSL: OFF
216216
uses: ashutoshvarma/action-cmake-build@master
217217
with:
218218
build-dir: ${{ github.workspace }}/build
@@ -224,6 +224,9 @@ jobs:
224224
windows-msvc-openssl:
225225
runs-on: windows-latest
226226
steps:
227+
- uses: actions/setup-python@v1
228+
- name: Install meson
229+
run: pip install meson
227230
- name: Install OpenSSL
228231
run: choco install openssl -y
229232
- name: Checkout
@@ -234,6 +237,7 @@ jobs:
234237
CPR_BUILD_TESTS: ON
235238
CPR_BUILD_TESTS_SSL: ON
236239
CPR_FORCE_OPENSSL_BACKEND: ON
240+
CURL_USE_LIBPSL: OFF
237241
uses: ashutoshvarma/action-cmake-build@master
238242
with:
239243
build-dir: ${{ github.workspace }}/build
@@ -248,12 +252,15 @@ jobs:
248252
buildType: [Debug, Release]
249253
runs-on: macos-latest
250254
steps:
255+
- name: Install libpsl
256+
run: brew install libpsl
251257
- name: Checkout
252258
uses: actions/checkout@v3
253259
- name: "Build & Test"
254260
env:
255261
CPR_BUILD_TESTS: ON
256262
CPR_BUILD_TESTS_SSL: OFF
263+
CPR_USE_SYSTEM_LIB_PSL: ON
257264
uses: ashutoshvarma/action-cmake-build@master
258265
with:
259266
build-dir: ${{ github.workspace }}/build
@@ -267,13 +274,16 @@ jobs:
267274
macos-clang-darwinssl:
268275
runs-on: macos-latest
269276
steps:
277+
- name: Install libpsl
278+
run: brew install libpsl
270279
- name: Checkout
271280
uses: actions/checkout@v3
272281
- name: "Build & Test"
273282
env:
274283
CPR_BUILD_TESTS: ON
275284
CPR_BUILD_TESTS_SSL: OFF
276285
CPR_FORCE_DARWINSSL_BACKEND: ON
286+
CPR_USE_SYSTEM_LIB_PSL: ON
277287
uses: ashutoshvarma/action-cmake-build@master
278288
with:
279289
build-dir: ${{ github.workspace }}/build
@@ -289,13 +299,16 @@ jobs:
289299
steps:
290300
- name: Install OpenSSL
291301
run: brew install openssl
302+
- name: Install libpsl
303+
run: brew install libpsl
292304
- name: Checkout
293305
uses: actions/checkout@v3
294306
- name: "Build & Test"
295307
env:
296308
CPR_BUILD_TESTS: ON
297309
CPR_BUILD_TESTS_SSL: ON
298310
CPR_FORCE_OPENSSL_BACKEND: ON
311+
CPR_USE_SYSTEM_LIB_PSL: ON
299312
OPENSSL_ROOT_DIR: "${{ env.MACOS_OPENSSL_ROOT_DIR }}"
300313
OPENSSL_LIBRARIES: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
301314
LDFLAGS: "-L${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
@@ -318,6 +331,8 @@ jobs:
318331
run: brew install boost
319332
- name: Install OpenSSL
320333
run: brew install openssl
334+
- name: Install libpsl
335+
run: brew install libpsl
321336
- name: Checkout
322337
uses: actions/checkout@v3
323338
- name: "Build & Test"
@@ -326,6 +341,7 @@ jobs:
326341
CPR_BUILD_TESTS_SSL: ON
327342
CPR_FORCE_OPENSSL_BACKEND: ON
328343
CPR_USE_BOOST_FILESYSTEM: ON
344+
CPR_USE_SYSTEM_LIB_PSL: ON
329345
OPENSSL_ROOT_DIR: "${{ env.MACOS_OPENSSL_ROOT_DIR }}"
330346
OPENSSL_LIBRARIES: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
331347
LDFLAGS: "-L${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"

.github/workflows/clang-tidy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- name: Update package list
1111
run: sudo dnf update -y
1212
- name: Install dependencies
13-
run: sudo dnf install -y openssl-devel cmake git gcc clang ninja-build
13+
run: sudo dnf install -y openssl-devel cmake git gcc clang ninja-build libpsl-devel meson
1414
- name: Install clang-tidy
1515
run: sudo dnf install -y clang-tools-extra
1616
- name: Checkout

.github/workflows/cppcheck.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ on: [push, workflow_dispatch, pull_request] # Trigger for every push as well as
55
jobs:
66
cppcheck:
77
runs-on: ubuntu-latest
8+
container: "fedora:latest" # Use fedora for an up to date version of cppcheck
89
steps:
910
- name: Checkout
1011
uses: actions/checkout@v3
11-
with:
12-
submodules: true
1312
- name: Update package list
14-
run: sudo apt update
15-
- name: Install cppcheck
16-
run: sudo apt install cppcheck
13+
run: dnf update -y
14+
- name: Install Dependencies
15+
run: dnf install -y gcc clang git gcc gdb make openssl-devel cmake libpsl-devel cppcheck meson
1716
- name: "[Release g++] Build"
1817
env:
1918
CPR_ENABLE_CPPCHECK: ON

CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ cpr_option(CPR_CURL_NOSIGNAL "Set to ON to disable use of signals in libcurl." O
5656
cpr_option(CURL_VERBOSE_LOGGING "Curl verbose logging during building curl" OFF)
5757
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)
5858
cpr_option(CPR_USE_SYSTEM_CURL "If enabled we will use the curl lib already installed on this system." OFF)
59+
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})
5960
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)
6061
cpr_option(CPR_ENABLE_SSL "Enables or disables the SSL backend. Required to perform HTTPS requests." ON)
6162
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)
@@ -294,10 +295,14 @@ else()
294295
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
295296
cmake_policy(SET CMP0135 NEW)
296297
endif()
297-
FetchContent_Declare(curl
298-
URL https://github.com/curl/curl/releases/download/curl-8_10_1/curl-8.10.1.tar.xz
299-
URL_HASH SHA256=73a4b0e99596a09fa5924a4fb7e4b995a85fda0d18a2c02ab9cf134bebce04ee # the file hash for curl-8.10.1.tar.xz
300-
USES_TERMINAL_DOWNLOAD TRUE) # <---- This is needed only for Ninja to show download progress
298+
299+
# Since curl 8.13, curl depends on lib psl
300+
if(NOT ${CPR_USE_SYSTEM_LIB_PSL})
301+
include(libpsl)
302+
endif()
303+
304+
FetchContent_Declare(curl URL https://github.com/curl/curl/releases/download/curl-8_13_0/curl-8.13.0.tar.xz
305+
URL_HASH SHA256=4a093979a3c2d02de2fbc00549a32771007f2e78032c6faa5ecd2f7a9e152025) # the file hash for curl-8.13.0.tar.xz
301306
FetchContent_MakeAvailable(curl)
302307

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

382387
file(INSTALL cmake/mongoose.CMakeLists.txt DESTINATION ${mongoose_SOURCE_DIR})
383388
file(RENAME ${mongoose_SOURCE_DIR}/mongoose.CMakeLists.txt ${mongoose_SOURCE_DIR}/CMakeLists.txt)

cmake/libpsl.cmake

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Builds libpsl which is especially necessary on Windows since there it is not available via e.g. a package manager.
2+
3+
include(ExternalProject)
4+
find_program(MESON_PATH meson)
5+
6+
if(MESON_PATH STREQUAL "MESON_PATH-NOTFOUND")
7+
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.")
8+
return()
9+
endif()
10+
11+
FetchContent_Declare(libpsl_src GIT_REPOSITORY https://github.com/rockdaboot/libpsl.git
12+
GIT_TAG 0.21.5)
13+
FetchContent_MakeAvailable(libpsl_src) # sets libpsl_src_SOURCE_DIR / _BINARY_DIR
14+
15+
set(LIBPSL_SOURCE_DIR "${libpsl_src_SOURCE_DIR}")
16+
set(LIBPSL_BUILD_DIR "${libpsl_src_BINARY_DIR}")
17+
set(LIBPSL_INSTALL_DIR "${CMAKE_BINARY_DIR}/libpsl_src-install")
18+
file(MAKE_DIRECTORY "${LIBPSL_BUILD_DIR}")
19+
20+
# Meson configure
21+
# We only care about static libraries of psl. In case you need a dynamic version, feel free to add support for it.
22+
message(STATUS "Configuring libpsl...")
23+
execute_process(COMMAND "${MESON_PATH}" setup
24+
"${LIBPSL_BUILD_DIR}"
25+
"${LIBPSL_SOURCE_DIR}"
26+
-Dtests=false
27+
-Ddocs=false
28+
--buildtype=release
29+
--prefix "${LIBPSL_INSTALL_DIR}"
30+
--default-library=static
31+
RESULT_VARIABLE MESON_SETUP_RC)
32+
if(MESON_SETUP_RC)
33+
message(FATAL_ERROR "Meson setup for libpsl failed!")
34+
endif()
35+
36+
# Meson build
37+
message(STATUS "Building libpsl...")
38+
execute_process(COMMAND "${MESON_PATH}" compile -C "${LIBPSL_BUILD_DIR}"
39+
RESULT_VARIABLE MESON_COMPILE_RC
40+
)
41+
if(MESON_COMPILE_RC)
42+
message(FATAL_ERROR "Meson compile for libpsl failed!")
43+
endif()
44+
45+
# Meson install
46+
message(STATUS "Installing libpsl...")
47+
execute_process(COMMAND "${MESON_PATH}" install -C "${LIBPSL_BUILD_DIR}"
48+
RESULT_VARIABLE MESON_INSTALL_RC)
49+
if(MESON_INSTALL_RC)
50+
message(FATAL_ERROR "Meson install for libpsl failed!")
51+
endif()
52+
53+
list(APPEND CMAKE_LIBRARY_PATH "${LIBPSL_INSTALL_DIR}/lib64")
54+
list(APPEND CMAKE_LIBRARY_PATH "${LIBPSL_INSTALL_DIR}/lib")
55+
list(APPEND CMAKE_INCLUDE_PATH "${LIBPSL_INSTALL_DIR}/include")
56+
57+
# Workaround for Windows compilation.
58+
# Ref: https://github.com/microsoft/vcpkg/pull/38847/files#diff-922fe829582a7e5acf5b0c35181daa63064fc12a2c889c5d89a19e5e02113f1bL44
59+
add_compile_definitions(PSL_STATIC=1)

0 commit comments

Comments
 (0)