Change #261911
| Category | None |
| Changed by | Viktor Szakats <commit@vsz.me> |
| Changed at | Sat 21 Mar 2026 18:52:31 |
| Repository | https://api.github.com/repos/curl/curl |
| Project | curl/curl |
| Branch | master |
| Revision | 8fce3e17e6cb310cd6dbe38ff14869b8fe5827d2 |
Comments
cmake: add CMake Config-based dependency detection After limiting `find_package()`/`find_dependency()` calls to curl local Find modules via the `MODULES` keyword, it became possible to detect dependencies via CMake Configs from within those local Find modules, by calling `find_package()` again with the `CONFIG` keyword. This patch implements this. Then maps detection results to the result variables and curl-specific imported targets the rest of the build expects. Also honor recently introduced `*_USE_STATIC_LIBS` (experimental) flags to map to the static target when requested. This adds CMake Configs as an alternative to the existing `pkg-config` and `find_path()`/`find_library()` auto-detection methods. Enabled by default for MSVC, outside vcpkg and when not cross-building. To enable for other cases, or override the default, you can use `-DCURL_USE_CMAKECONFIG=ON` or `OFF`. When enabled, Config detection happens after `pkg-config` and before `find_path()`/`find_library()`. Using CMake's built-in options, you may also manually point to the absolute directory holding Config files: `Libssh2_DIR`, `MbedTLS_DIR`, `NGHTTP2_DIR`, `NGHTTP3_DIR`, `NGTCP2_DIR` v1.19.0+ (with non-fork OpenSSL only), `Zstd_DIR` v1.4.5+ E.g. `-DMbedTLS_DIR=/path/to/mbedtls/lib/cmake/MbedTLS` These dependencies typically need to be built with CMake to support this. Tagged as experimental. Refs: #20013 #19156 #19117 https://github.com/curl/curl/pull/20784#issuecomment-3984318492 Depends-on: fad1ebaecc0c489d38c0a9a155f63fdfd9086907 #20840 Follow-up to 91e06fde1b520bc29c7996749734451e03cd549f #20784 Follow-up to 26c39d8df182a63d28d81ed2b044e6a343519d1a #20015 Closes #20814
Changed files
- .github/workflows/configure-vs-cmake.yml
- CMake/FindLibssh2.cmake
- CMake/FindMbedTLS.cmake
- CMake/FindNGHTTP2.cmake
- CMake/FindNGHTTP3.cmake
- CMake/FindNGTCP2.cmake
- CMake/FindZstd.cmake
- CMake/curl-config.in.cmake
- CMakeLists.txt
- docs/INSTALL-CMAKE.md
- tests/cmake/CMakeLists.txt