mirror of
https://github.com/curl/curl.git
synced 2026-04-15 02:31:40 +03:00
cmake: fix building with CMAKE_FIND_PACKAGE_PREFER_CONFIG=ON
This CMake global custom option tells it to find dependencies as cmake Configs first, and only then look for `Find*` modules. This may result in `find_package()` succeeding, but without actually creating `CURL::*` imported targets the curl build scripts are expecting. For dependencies with curl-specific, local, `Find*` modules, we always want to use them, via the module detection method, and never a Config-based detection. Ensure this by passing the `MODULE` option to `find_package()` and `find_dependency()` to make them use `Find*` modules unconditionally, making them work as expected with the `CMAKE_FIND_PACKAGE_PREFER_CONFIG=ON` option set. curl uses local Find modules for all dependencies except OpenSSL and ZLIB. The latter two keep using either CMake's built-in Find modules or Config method as before this patch. Also: - apply the same change to `curl-config.cmake`. To fix consuming curl with this option set. Authored-by: Valerie Snyder Ref: #20764 Follow-up to16f073ef49#16973 - GHA/distcheck: add a job testing both building and consuming curl with this option set. (takes 15 seconds) Use custom NGHTTP2 configuration for an extra twist (not required to trigger this issue.) Follow-up tofcde8d7e37#20773 Reported-by: Valerie Snyder Fixes #20729 Closes #20784
This commit is contained in:
parent
3d708e239b
commit
91e06fde1b
4 changed files with 64 additions and 50 deletions
6
.github/workflows/distcheck.yml
vendored
6
.github/workflows/distcheck.yml
vendored
|
|
@ -319,6 +319,12 @@ jobs:
|
|||
- name: 'via find_package (C++)'
|
||||
if: ${{ contains(matrix.image, 'ubuntu') }}
|
||||
run: TEST_CMAKE_FLAGS=-DTEST_CPP=ON ./tests/cmake/test.sh find_package ${TESTOPTS} -DCURL_USE_OPENSSL=ON
|
||||
- name: 'via find_package (PREFER_CONFIG=ON)'
|
||||
if: ${{ contains(matrix.image, 'windows') }}
|
||||
run: |
|
||||
export TEST_CMAKE_FLAGS_PROVIDER='-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON -DCURL_ZSTD=OFF -DNGHTTP2_INCLUDE_DIR=C:/msys64/mingw64/include -DNGHTTP2_LIBRARY=C:/msys64/mingw64/lib/libnghttp2.dll.a'
|
||||
export TEST_CMAKE_FLAGS_CONSUMER="${TEST_CMAKE_FLAGS_PROVIDER}"
|
||||
./tests/cmake/test.sh find_package ${TESTOPTS} -DCURL_USE_OPENSSL=ON
|
||||
|
||||
- name: 'via ExternalProject (old cmake)'
|
||||
if: ${{ contains(matrix.image, 'ubuntu') }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue