cmake: drop support for CMake 3.17 and older

Require CMake 3.18 (2020-07-15) or newer, up from 3.7 (2016-11-11)
prior to this patch.

This requirement also applies to the distributed `curl-config.cmake`.

To allow dropping compatibility code maintained for old versions, and to
use features which were unpractical in separate code paths. Also to make
testing, documentation and development easier, CI builds faster due to
CMake performance improvements over time. (e.g. integration tests on
macOS run 8x faster (10 minutes is now under 1.5m) in CI, 2.5x faster on
Windows.)

CMake offers pre-built binaries for major platforms. They work without
an install step, just by unpacking and pointing the cmake command to
them. Making upgrades easy in many cases:
https://cmake.org/download/
https://cmake.org/files/
https://github.com/Kitware/CMake/releases

CMake 3.18 brings these feature as generally available when building or
consuming curl/libcurl:

LTO support, improved performance, `pkg-config` and interface target
support, `OBJECT` target (for faster libcurl builds), modern invocation
with `-S`/`-B` options, better support for custom linker options,
FetchContent, `GnuTLS::GnuTLS` target, `--verbose` and `--install`
options, `CMAKE_GENERATOR` env, last but not least unity mode and Ninja
generator.

For maximum build speed, use:
`-DCMAKE_UNITY_BUILD=ON -DCURL_DROP_UNUSED=ON`

As for deprecations, C++11 is required to build CMake itself, which may
be a limit on some platforms. autotools continues to cover them.

Follow-up to 9bcdfb3809 #20408
Follow-up to a7c974e038 #19902
Follow-up to dfbe035c8b #10161
Discussion: https://github.com/curl/curl/discussions/18704

Closes #20407
This commit is contained in:
Viktor Szakats 2025-11-26 19:07:19 +01:00
parent d5014a2b95
commit 89043ba906
No known key found for this signature in database
35 changed files with 75 additions and 348 deletions

View file

@ -69,7 +69,7 @@ jobs:
sha256sum freexian-archive-keyring_2022.06.08_all.deb && dpkg -i freexian-archive-keyring_2022.06.08_all.deb
echo 'deb http://deb.freexian.com/extended-lts stretch-lts main contrib non-free' | tee /etc/apt/sources.list.d/extended-lts.list
apt-get -o Dpkg::Use-Pty=0 update
apt-get -o Dpkg::Use-Pty=0 install -y --no-install-suggests --no-install-recommends make automake autoconf libtool gcc pkg-config libpsl-dev libzstd-dev zlib1g-dev libc-ares-dev libkrb5-dev libldap2-dev librtmp-dev stunnel4
apt-get -o Dpkg::Use-Pty=0 install -y --no-install-suggests --no-install-recommends make automake autoconf libtool ninja-build gcc pkg-config libpsl-dev libzstd-dev zlib1g-dev libc-ares-dev libkrb5-dev libldap2-dev librtmp-dev stunnel4
# GitHub's actions/checkout needs newer glibc and libstdc++. The latter also depends on
# gcc-8-base, but it does not actually seem used in our situation and is not available in
# the main repo, so force the install.
@ -79,8 +79,8 @@ jobs:
- name: 'install prereqs (cmake)'
env:
CMAKE_VERSION: 3.7.0 # Earliest version supported by curl
CMAKE_SHA256: e075f63e6a9104b1c3d11666ae9546bc8812f7e791a49c4ce11effc063141b2a
CMAKE_VERSION: 3.18.0 # Earliest version supported by curl
CMAKE_SHA256: 4d9a9d3351161073a67e49366d701b6fa4b0343781982dc5eef08a02a750d403
run: |
cd ~
fn="cmake-${CMAKE_VERSION}-linux-x86_64"
@ -94,13 +94,13 @@ jobs:
- name: 'CM build-only configure (out-of-tree)'
run: |
mkdir bld-1
cd bld-1
~/cmake/bin/cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \
~/cmake/bin/cmake -B bld-1 -G Ninja -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \
-DCURL_ENABLE_SSL=OFF -DENABLE_ARES=OFF -DCURL_ZSTD=OFF -DCURL_USE_GSSAPI=OFF -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=OFF -DUSE_LIBRTMP=ON
- name: 'CM build-only build'
run: VERBOSE=1 make -C bld-1 install
run: |
~/cmake/bin/cmake --build bld-1 --verbose
~/cmake/bin/cmake --install bld-1 --verbose
- name: 'CM build-only curl -V'
run: bld-1/src/curl --disable --version
@ -118,9 +118,7 @@ jobs:
# that enabled again
- name: 'CM configure (out-of-tree, c-ares, zstd, gssapi)'
run: |
mkdir bld-cares
cd bld-cares
~/cmake/bin/cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \
~/cmake/bin/cmake -B bld-cares -G Ninja -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \
-DCURL_ENABLE_SSL=OFF -DENABLE_ARES=ON -DCURL_USE_GSSAPI=ON -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=OFF -DUSE_LIBRTMP=ON \
-DCURL_LIBCURL_VERSIONED_SYMBOLS=ON
@ -134,22 +132,22 @@ jobs:
grep -F '#define' bld-cares/lib/curl_config.h | sort || true
- name: 'CM build'
run: make -C bld-cares
run: ~/cmake/bin/cmake --build bld-cares
- name: 'CM curl -V'
run: bld-cares/src/curl --disable --version
- name: 'CM install'
run: make -C bld-cares install
run: ~/cmake/bin/cmake --install bld-cares
- name: 'CM build tests'
run: make -C bld-cares testdeps
run: ~/cmake/bin/cmake --build bld-cares --target testdeps
- name: 'CM run tests'
run: make -C bld-cares test-ci
run: ~/cmake/bin/cmake --build bld-cares --target test-ci
- name: 'CM build examples'
run: make -C bld-cares curl-examples-build
run: ~/cmake/bin/cmake --build bld-cares --target curl-examples-build
- name: 'AM autoreconf'
run: autoreconf -fi