Repository navigation
Conversation
f45ce62 to
ae36d59
Compare
This comment was marked as resolved.
This comment was marked as resolved.
9fad9a2 to
c8d6f9f
Compare
c8d6f9f to
dd88810
Compare
curl-config.cmake
f6d224c to
b694645
Compare
b694645 to
2118f46
Compare
6f2fc8e to
48bfb9e
Compare
48bfb9e to
dfc28ab
Compare
|
This PR is plan to merge in the next release window? |
|
Ideally yes. The blocker is to have some CI tests for this. And for that, the blocker is a breakage in the The breakage came in CI after bumping a version in the above PR, but the conditions are fuzzy and couldn't fix it. Edit: + as the PR message says, it'd be nice to give some testing to the newly added Find modules first. |
I think you can do manual usage test without |
I use those scripts for manual local tests. There are 3 usage tests, and Locally it fails regardless of CMake version (It might have worked I'd expect it to build the project, but it doesn't. In CI, it started failing after a minor patch to the diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0eee9467..8a5eeb29 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,7 +36,7 @@
#
# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.7)
+cmake_minimum_required(VERSION 3.7...3.16 FATAL_ERROR)
message(STATUS "Using CMake version ${CMAKE_VERSION}")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
diff --git a/tests/cmake/CMakeLists.txt b/tests/cmake/CMakeLists.txt
index 97317595..ce3a7470 100644
--- a/tests/cmake/CMakeLists.txt
+++ b/tests/cmake/CMakeLists.txt
@@ -1,7 +1,7 @@
# Copyright (C) Viktor Szakats
# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.7)
+cmake_minimum_required(VERSION 3.7...3.16 FATAL_ERROR)
message(STATUS "Using CMake version ${CMAKE_VERSION}")
project(test-dependent C) |
|
@vszakats I understand now the complexity of this PR. instead of: For each package that have 2 option of detection: one with find_package and the other is with pkg-conf, it needed to add the correct to |
|
I understand what you say. That find_dependency() will call curl custom find_package for each curl package, then inside it will be detected by find_package or by pkg-conf. Did you tested that |
No, I have not, yet. Just assuming that's the point of having and distributing Find modules. This was done last year in libssh2, but I haven't tested it myself: |
| find_dependency(NGTCP2) | ||
| endif() | ||
| if("@USE_GNUTLS@") | ||
| if(CURL_USE_PKGCONFIG) |
There was a problem hiding this comment.
This is should be like:
"@CURL_USE_PKGCONFIG@"
There was a problem hiding this comment.
This is should be like: "@CURL_USE_PKGCONFIG@"?
Isn't this case the same as similar uses within our Find* modules?
Those allow CURL_USE_PKGCONFIG be set by the user of the curl
package to select if they want pkg-config to kick in to find dependencies.
We initialize it at the beginning of the config script.
GnuTLS looks like the same case as the others. Difference is, GnuTLS
does have a CMake built-in Find module, without pkg-config support,
which we tackled on ourselves, then call the built-in module.
There was a problem hiding this comment.
You need to remember that this file is load after the curl is compiled, before the generated export cmake is loaded. there is no symbol CURL_USE_PKGCONFIG. that why you need to add as I suggested. also you did it for all other curl variables in this files for the same reason.
There was a problem hiding this comment.
I just see that you define it in the beginning of this files. I think we should delete this from here, and have the defintion in one place (in the main cmake, as it already there), and remember that the user decide when it compile it, then set this option permanent for that compilation.
There was a problem hiding this comment.
The generated curl-config.cmake does initialize CURL_USE_PKGCONFIG, at the top of the script:
curl/CMake/curl-config.cmake.in
Lines 26 to 34 in 7e814c8
It uses the same init logic as curl's build script, but this one is evaluated when building the dependent project. Is there something missing?
There was a problem hiding this comment.
Typical Find module trouble:
WolfSSL has CMake config and pkgconfig both export -lm on Linux. Curl uses a find module. This the result:
FAILED: main-pkgconfig
: && /usr/lib/ccache/cc -fPIC -g -pthread CMakeFiles/main-pkgconfig.dir/main.c.o -o main-pkgconfig /vcpkg/installed/x64-linux/debug/lib/libcurl-d.a -latomic -lm /vcpkg/installed/x64-linux/debug/lib/libgssapi_krb5.a /vcpkg/installed/x64-linux/debug/lib/libkrb5.a /vcpkg/installed/x64-linux/debug/lib/libk5crypto.a /vcpkg/installed/x64-linux/debug/lib/libcom_err.a /vcpkg/installed/x64-linux/debug/lib/libkrb5support.a /usr/lib/x86_64-linux-gnu/libresolv.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libpthread.so /vcpkg/installed/x64-linux/debug/lib/libldap.a /vcpkg/installed/x64-linux/debug/lib/liblber.a /vcpkg/installed/x64-linux/debug/lib/libcares.a /vcpkg/installed/x64-linux/debug/lib/libmbedtls.a /vcpkg/installed/x64-linux/debug/lib/libmbedx509.a /vcpkg/installed/x64-linux/debug/lib/libmbedcrypto.a /vcpkg/installed/x64-linux/debug/lib/libwolfssl.a /vcpkg/installed/x64-linux/debug/lib/libgnutls.a /vcpkg/installed/x64-linux/debug/lib/libhogweed.a /vcpkg/installed/x64-linux/debug/lib/libgmp.a /vcpkg/installed/x64-linux/debug/lib/libtasn1.a /vcpkg/installed/x64-linux/debug/lib/libnettle.a /vcpkg/installed/x64-linux/debug/lib/libbrotlidec.a /vcpkg/installed/x64-linux/debug/lib/libbrotlicommon.a /vcpkg/installed/x64-linux/debug/lib/libzstd.a /vcpkg/installed/x64-linux/debug/lib/libnghttp2.a /vcpkg/installed/x64-linux/debug/lib/libpsl.a /vcpkg/installed/x64-linux/debug/lib/libidn2.a /vcpkg/installed/x64-linux/debug/lib/libunistring.a /vcpkg/installed/x64-linux/lib/librtmp.a /vcpkg/installed/x64-linux/debug/lib/libz.a /vcpkg/installed/x64-linux/debug/lib/libssl.a /vcpkg/installed/x64-linux/debug/lib/libcrypto.a /usr/lib/x86_64-linux-gnu/libresolv.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libpthread.so /vcpkg/installed/x64-linux/debug/lib/libldap.a /vcpkg/installed/x64-linux/debug/lib/liblber.a /vcpkg/installed/x64-linux/debug/lib/libcares.a /vcpkg/installed/x64-linux/debug/lib/libmbedtls.a /vcpkg/installed/x64-linux/debug/lib/libmbedx509.a /vcpkg/installed/x64-linux/debug/lib/libmbedcrypto.a /vcpkg/installed/x64-linux/debug/lib/libwolfssl.a /vcpkg/installed/x64-linux/debug/lib/libgnutls.a /vcpkg/installed/x64-linux/debug/lib/libhogweed.a /vcpkg/installed/x64-linux/debug/lib/libgmp.a /vcpkg/installed/x64-linux/debug/lib/libtasn1.a /vcpkg/installed/x64-linux/debug/lib/libnettle.a /vcpkg/installed/x64-linux/debug/lib/libbrotlidec.a /vcpkg/installed/x64-linux/debug/lib/libbrotlicommon.a /vcpkg/installed/x64-linux/debug/lib/libzstd.a /vcpkg/installed/x64-linux/debug/lib/libnghttp2.a /vcpkg/installed/x64-linux/debug/lib/libpsl.a /vcpkg/installed/x64-linux/debug/lib/libidn2.a /vcpkg/installed/x64-linux/debug/lib/libunistring.a /vcpkg/installed/x64-linux/lib/librtmp.a /vcpkg/installed/x64-linux/debug/lib/libz.a /vcpkg/installed/x64-linux/debug/lib/libssl.a /vcpkg/installed/x64-linux/debug/lib/libcrypto.a && :
/usr/bin/ld: /vcpkg/installed/x64-linux/debug/lib/libwolfssl.a(dh.c.o): in function `DiscreteLogWorkFactor':
/vcpkg/buildtrees/wolfssl/src/7.6-stable-6ac16c75a4.clean/wolfcrypt/src/dh.c:1031: undefined reference to `pow'
/usr/bin/ld: /vcpkg/buildtrees/wolfssl/src/7.6-stable-6ac16c75a4.clean/wolfcrypt/src/dh.c:1032: undefined reference to `log'
/usr/bin/ld: /vcpkg/buildtrees/wolfssl/src/7.6-stable-6ac16c75a4.clean/wolfcrypt/src/dh.c:1032: undefined reference to `pow'
collect2: error: ld returned 1 exit status
There was a problem hiding this comment.
That's another missing piece of this puzzle, thanks for this.
curl never referenced dependencies like this except for OpenSSL and ZLIB. It's also been CMake version dependent, but that seems clear now (for OpenSSL it required CMake 3.4, for ZLIB it was 3.1). curl never declared INTERFACE_LINK_LIBRARIES, which seems something to be fixed. It's also a question how to use the ::-style references with other dependencies. Those also use custom Find modules. So another question is how to reference them like this AND provide support for pkg-config. I'm assuming we must define those targets manually in such case.
For now it seems safe to just convert this PR to a tidy-up one that deletes the CURL_USE_PKGCONFIG logic from curl-config.cmake. The rest needs somebody who knows how to do it.
There was a problem hiding this comment.
Opened #16087 for the tidy-up. This PR also has this, plus converted to add the CONFIG modules, though this might be pointless too without using :: and INTERFACE_LINK_LIBRARIES. So unless there is a better suggestion, I plan to close this shortly without merging.
There was a problem hiding this comment.
Typical Find module trouble: WolfSSL has CMake config and pkgconfig both export
-lmon Linux. Curl uses a find module. This the result:FAILED: main-pkgconfig : && /usr/lib/ccache/cc -fPIC -g -pthread CMakeFiles/main-pkgconfig.dir/main.c.o -o main-pkgconfig /vcpkg/installed/x64-linux/debug/lib/libcurl-d.a -latomic -lm /vcpkg/installed/x64-linux/debug/lib/libgssapi_krb5.a /vcpkg/installed/x64-linux/debug/lib/libkrb5.a /vcpkg/installed/x64-linux/debug/lib/libk5crypto.a /vcpkg/installed/x64-linux/debug/lib/libcom_err.a /vcpkg/installed/x64-linux/debug/lib/libkrb5support.a /usr/lib/x86_64-linux-gnu/libresolv.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libpthread.so /vcpkg/installed/x64-linux/debug/lib/libldap.a /vcpkg/installed/x64-linux/debug/lib/liblber.a /vcpkg/installed/x64-linux/debug/lib/libcares.a /vcpkg/installed/x64-linux/debug/lib/libmbedtls.a /vcpkg/installed/x64-linux/debug/lib/libmbedx509.a /vcpkg/installed/x64-linux/debug/lib/libmbedcrypto.a /vcpkg/installed/x64-linux/debug/lib/libwolfssl.a /vcpkg/installed/x64-linux/debug/lib/libgnutls.a /vcpkg/installed/x64-linux/debug/lib/libhogweed.a /vcpkg/installed/x64-linux/debug/lib/libgmp.a /vcpkg/installed/x64-linux/debug/lib/libtasn1.a /vcpkg/installed/x64-linux/debug/lib/libnettle.a /vcpkg/installed/x64-linux/debug/lib/libbrotlidec.a /vcpkg/installed/x64-linux/debug/lib/libbrotlicommon.a /vcpkg/installed/x64-linux/debug/lib/libzstd.a /vcpkg/installed/x64-linux/debug/lib/libnghttp2.a /vcpkg/installed/x64-linux/debug/lib/libpsl.a /vcpkg/installed/x64-linux/debug/lib/libidn2.a /vcpkg/installed/x64-linux/debug/lib/libunistring.a /vcpkg/installed/x64-linux/lib/librtmp.a /vcpkg/installed/x64-linux/debug/lib/libz.a /vcpkg/installed/x64-linux/debug/lib/libssl.a /vcpkg/installed/x64-linux/debug/lib/libcrypto.a /usr/lib/x86_64-linux-gnu/libresolv.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libpthread.so /vcpkg/installed/x64-linux/debug/lib/libldap.a /vcpkg/installed/x64-linux/debug/lib/liblber.a /vcpkg/installed/x64-linux/debug/lib/libcares.a /vcpkg/installed/x64-linux/debug/lib/libmbedtls.a /vcpkg/installed/x64-linux/debug/lib/libmbedx509.a /vcpkg/installed/x64-linux/debug/lib/libmbedcrypto.a /vcpkg/installed/x64-linux/debug/lib/libwolfssl.a /vcpkg/installed/x64-linux/debug/lib/libgnutls.a /vcpkg/installed/x64-linux/debug/lib/libhogweed.a /vcpkg/installed/x64-linux/debug/lib/libgmp.a /vcpkg/installed/x64-linux/debug/lib/libtasn1.a /vcpkg/installed/x64-linux/debug/lib/libnettle.a /vcpkg/installed/x64-linux/debug/lib/libbrotlidec.a /vcpkg/installed/x64-linux/debug/lib/libbrotlicommon.a /vcpkg/installed/x64-linux/debug/lib/libzstd.a /vcpkg/installed/x64-linux/debug/lib/libnghttp2.a /vcpkg/installed/x64-linux/debug/lib/libpsl.a /vcpkg/installed/x64-linux/debug/lib/libidn2.a /vcpkg/installed/x64-linux/debug/lib/libunistring.a /vcpkg/installed/x64-linux/lib/librtmp.a /vcpkg/installed/x64-linux/debug/lib/libz.a /vcpkg/installed/x64-linux/debug/lib/libssl.a /vcpkg/installed/x64-linux/debug/lib/libcrypto.a && : /usr/bin/ld: /vcpkg/installed/x64-linux/debug/lib/libwolfssl.a(dh.c.o): in function `DiscreteLogWorkFactor': /vcpkg/buildtrees/wolfssl/src/7.6-stable-6ac16c75a4.clean/wolfcrypt/src/dh.c:1031: undefined reference to `pow' /usr/bin/ld: /vcpkg/buildtrees/wolfssl/src/7.6-stable-6ac16c75a4.clean/wolfcrypt/src/dh.c:1032: undefined reference to `log' /usr/bin/ld: /vcpkg/buildtrees/wolfssl/src/7.6-stable-6ac16c75a4.clean/wolfcrypt/src/dh.c:1032: undefined reference to `pow' collect2: error: ld returned 1 exit status
I don't understand. Does this have to do anything with this PR? Is this a bug report for FindWolfSSL?
There is this code in FindWolfSSL to find -lm, does it not work?
Lines 93 to 99 in 49ece64
There was a problem hiding this comment.
After working on this incomrehesinble jumble of nonense for more than a year, I feel I can do no more to satisfy the random and often straight contradictory reports, requests and comments just sprinkled in. I'm passing the opportunity to someone who knows it better.
dfc28ab to
d18c95a
Compare
d18c95a to
bb13fae
Compare
This variable was meant to be used by curl Find modules, but it turns out it makes no sense to use those from `curl-config.cmake.in`. Drop it. Also add missing macros passed to curl-config.cmake to comment. Ref: curl#14930 (comment)
This variable was meant to be used by curl Find modules, but it turns out it makes no sense to use those from `curl-config.cmake.in`. It means this variable was not used before and will not be used in the future, and therefore safe to delete. Also add missing macros passed to `curl-config.cmake` to comment. Ref: #14930 (comment) Closes #16087
|
For reference, I try tackling this in libssh2, on a smaller scale:
|
|
How it goes? Are you thinking to apply it on curl? |
It's bumpy. CMake misses features necessary for this in versions The direction of using target props instead of global variables is It's also very suprising that CMake to this day misses a way to I believe CMake would make great service for everyone by offering TL;DR: It's probably possible to build on that and implement some (or You can find the details here: libssh2/libssh2#1535 |
|
I wanted also you look at this vcpkg PR and it patches: |
@dg0yt How you debug on cmake? I remember that you told me that there is an option to do so. |
|
The best tools, and the crudest ones at the same time, are |
|
Nice! some random feedback:
|
|
Also this PR: |
|
Thanks for the debug tips! Found some new options I'll be testing (see below). Most of them are overkill for my use cases. The problem is rarely the control flow, but the values stored by CMake. I prefer the Tried Fix applied: |
This variable was meant to be used by curl Find modules, but it turns out it makes no sense to use those from `curl-config.cmake.in`. It means this variable was not used before and will not be used in the future, and therefore safe to delete. Also add missing macros passed to `curl-config.cmake` to comment. Ref: curl#14930 (comment) Closes curl#16087
Rework the way curl's custom Find modules advertise their properties. Before this patch, Find modules returned detected dependency properties (header dirs, libs, libdirs, C flags, etc.) via global variables. curl's main `CMakeLists.txt` copied their values into global lists, which it later applied to targets. This solution worked internally, but it was unsuited for the public, distributed `CURLConfig.cmake` and publishing curl's Find modules with it, due to polluting the namespace of consumer projects. It's also impractical to apply the many individual variables to every targets depending on libcurl. To allow using Find modules in consumer projects, this patch makes them define as imported interface targets, named `CURL::<dependency>`. Then store dependency information as target properties. It avoids namespace pollution and makes the dependency information apply automatically to all targets using `CURL::libcurl_static`. Find modules continue to return `*_FOUND` and `*_VERSION` variables. For dependencies detected via `pkg-config`, CMake 3.16+ is recommended. Older CMake versions have a varying degree of support for propagating/handling library directories. This may cause issues in envs where dependencies reside in non-system locations and detected via `pkg-config` (e.g. macOS + Homebrew). Use `CURL_USE_PKGCONFIG=OFF` to fix these issues. Or upgrade to newer CMake, or link libcurl dynamically. Also: - re-enable `pkg-config` for old cmake `find_library()` integration tests. - make `curlinfo` build after these changes. - distribute local Find modules. - export the raw list of lib dependencies via `CURL_LIBRARIES_PRIVATE`. - `CURLconfig.cmake`: use curl's Find modules to detect dependencies in the consumer env. - add custom property to target property debug function. - the curl build process no longer modifies `CMAKE_C_FLAGS`. Follow-up to e865420 #17047 Ref: #14930 Ref: libssh2/libssh2#1535 Ref: libssh2/libssh2#1571 Ref: libssh2/libssh2#1581 Ref: libssh2/libssh2#1623 Closes #16973
Detect more dependencies that provide a CMake config script.
Also:
CURL_USE_PKGCONFIGlogic, that unnecessary and will not beused, because using curl-specific Find modules make no sense here.
curl-config.cmaketo comment.librtmpFind module #15832 is merged.