← Commit list

fad1ebaecc

Viktor Szakats
Viktor Szakats
2026-03-16
SUCCESS Duration: 279s

Subject

cmake: resolve imported targets recursively when generating `libcurl.pc`

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

CMake/Macros.cmake+32 -0
@@ -252,3 +252,35 @@ function(curl_add_clang_tidy_test_target _target_clang_tidy _target)
add_dependencies(tests-clang-tidy ${_target_clang_tidy})
endif()
endfunction()
+
+# Internal: Recurse into interface targets and collect their libraries
+# and library paths.
+macro(curl_collect_target_link_options _target)
+ get_target_property(_val ${_target} INTERFACE_LINK_DIRECTORIES)
+ if(_val)
+ list(APPEND _libdirs ${_val})
+ endif()
+ get_target_property(_val ${_target} IMPORTED)
+ if(_val)
+ # LOCATION is empty for interface library targets and safe to ignore.
+ # Explicitly skip this query to avoid CMake v3.18 and older erroring out.
+ get_target_property(_val ${_target} TYPE)
+ if(NOT "${_val}" STREQUAL "INTERFACE_LIBRARY")
+ get_target_property(_val ${_target} LOCATION)
+ if(_val)
+ list(APPEND _libs ${_val})
+ endif()
+ endif()
+ endif()
+ get_target_property(_val ${_target} INTERFACE_LINK_LIBRARIES)
+ if(_val)
+ foreach(_lib IN LISTS _val)
+ if(TARGET "${_lib}")
+ curl_collect_target_link_options(${_lib})
+ else()
+ list(APPEND _libs ${_lib})
+ endif()
+ endforeach()
+ endif()
+ unset(_val)
+endmacro()
CMakeLists.txt+6 -20
@@ -2167,26 +2167,12 @@ if(NOT CURL_DISABLE_INSTALL)
# Assume the user will not need this information in the .pc file.
continue()
endif()
- if(_lib MATCHES "CURL::")
- # This is empty for 'CURL::*' targets and safe to ignore.
- # Explicitly skip this query to avoid CMake v3.18 and older erroring out.
- set(_libname "")
- else()
- get_target_property(_libname "${_lib}" LOCATION)
- endif()
- if(_libname)
- list(APPEND _explicit_libs "${_libname}")
- else()
- get_target_property(_libs "${_lib}" INTERFACE_LINK_LIBRARIES)
- if(_libs)
- list(APPEND _explicit_libs "${_libs}")
- endif()
- get_target_property(_libdirs "${_lib}" INTERFACE_LINK_DIRECTORIES)
- if(_libdirs)
- list(APPEND _explicit_libdirs "${_libdirs}")
- endif()
- endif()
- if(NOT _libname AND NOT _libs AND NOT _libdirs)
+ set(_libdirs "")
+ set(_libs "")
+ curl_collect_target_link_options("${_lib}") # look into the target recursively
+ list(APPEND _explicit_libdirs ${_libdirs})
+ list(APPEND _explicit_libs ${_libs})
+ if(NOT _libs AND NOT _libdirs)
message(WARNING "Bad lib in library list: ${_lib}")
endif()
if(_lib STREQUAL OpenSSL::SSL)