Skip to content

cmake: fixup Libs.private lib order - #1623

Closed
vszakats wants to merge 3 commits into
libssh2:masterfrom
vszakats:cm-pc-order-fix
Closed

vszakats wants to merge 3 commits into
libssh2:masterfrom
vszakats:cm-pc-order-fix

Conversation

@vszakats

@vszakats vszakats commented Jul 13, 2025 •

Copy link
Copy Markdown
Member

@vszakats vszakats added the build label Jul 13, 2025
@vszakats vszakats closed this in ad8e924 Jul 13, 2025
@vszakats
vszakats deleted the cm-pc-order-fix branch July 13, 2025 23:35
vszakats added a commit to curl/curl that referenced this pull request Nov 29, 2025
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant