Skip to content

cmake configuration fails with custom provided zlib #5512

Description

@malytomas

I am using curl with add_subdirectory in cmake. I have custom zlib (zlib-ng actually), and I provide target ZLIB::ZLIB as an interface library, which has dependency on another target. The target ZLIB::ZLIB does not have (and cannot have) the property LOCATION.

Unfortunately, recent changes to curl cmake:

get_target_property(_lib "${_lib}" LOCATION)

generates this error in my setup:

-- Enabled features: SSL IPv6 libz AsynchDNS SSPI SPNEGO Kerberos NTLM
-- Enabled protocols: HTTP HTTPS
-- Enabled SSL backends: WinSSL
CMake Error at externals/curl/curl/CMakeLists.txt:1416 (get_target_property):
  INTERFACE_LIBRARY targets may only have whitelisted properties.  The
  property "LOCATION" is not allowed.

CMake Warning at externals/curl/curl/CMakeLists.txt:1418 (message):
  Bad lib in library list: ZLIB::ZLIB

The code does not seem to have any effect and commenting it worked for me.

foreach(_lib ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${CURL_LIBS})
  #if(TARGET "${_lib}")
  #  set(_libname "${_lib}")
  #  get_target_property(_lib "${_lib}" LOCATION)
  #  if(NOT _lib)
  #    message(WARNING "Bad lib in library list: ${_libname}")
  #    continue()
  #  endif()
  #endif()
  if(_lib MATCHES ".*/.*" OR _lib MATCHES "^-")
    set(LIBCURL_LIBS          "${LIBCURL_LIBS} ${_lib}")
  else()
    set(LIBCURL_LIBS          "${LIBCURL_LIBS} -l${_lib}")
  endif()
endforeach()

curl/libcurl version

commit 2bf7d1b

operating system

Windows 10
cmake version 3.17.3
(msvc 16.6.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions