CMake: ignore INTERFACE_LIBRARY targets for pkg-config file

Reviewed-by: Marcel Raad
Fixes #5512
Closes #5517
This commit is contained in:
Peter Wu 2020-06-04 11:28:01 +02:00 committed by Daniel Stenberg
parent e39a6e2cea
commit 26d2755d7c
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
1 changed files with 9 additions and 1 deletions

View File

@ -1413,7 +1413,15 @@ set(libdir "${CMAKE_INSTALL_PREFIX}/lib")
foreach(_lib ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${CURL_LIBS})
if(TARGET "${_lib}")
set(_libname "${_lib}")
get_target_property(_lib "${_lib}" LOCATION)
get_target_property(_libtype "${_libname}" TYPE)
if(_libtype STREQUAL INTERFACE_LIBRARY)
# Interface libraries can occur when an external project embeds curl and
# defined targets such as ZLIB::ZLIB by themselves. Ignore these as
# reading the LOCATION property will error out. Assume the user won't need
# this information in the .pc file.
continue()
endif()
get_target_property(_lib "${_libname}" LOCATION)
if(NOT _lib)
message(WARNING "Bad lib in library list: ${_libname}")
continue()