]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: avoid setting custom property on built-in interface targets
authorViktor Szakats <commit@vsz.me>
Wed, 14 Jan 2026 12:04:18 +0000 (13:04 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 14 Jan 2026 19:46:25 +0000 (20:46 +0100)
In some cases `ZLIB::ZLIB` and/or `OpenSSL::SSL` may be aliases, which
prevents setting a curl-specific property (.pc module name) in them:
```
CMake Error at [...]/curl/CMakeLists.txt:910 (set_target_properties):
  set_target_properties can not be used on an ALIAS target.
```

Fix by special-casing these built-in targets and manually converting
them to .pc module names, without using the targets themselves
to carry this information throughout curl's internal build logic.

Reported-by: Tomáš Malý
Fixes #20313
Follow-up to 16f073ef49f94412000218c9f6ad04e3fd7e4d01 #16973
Closes #20316

CMakeLists.txt

index e70d47563c71cd515336a4952357817d00c59d92..55d88d69d7dfa11c8fb8556783f7a4585aba76cb 100644 (file)
@@ -767,7 +767,6 @@ if(CURL_USE_OPENSSL)
   # Depend on OpenSSL via imported targets. This allows our dependents to
   # get our dependencies transitively.
   list(APPEND CURL_LIBS OpenSSL::SSL OpenSSL::Crypto)
-  set_target_properties(OpenSSL::SSL PROPERTIES INTERFACE_LIBCURL_PC_MODULES "openssl")
 
   if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "openssl")
     set(_valid_default_ssl_backend TRUE)
@@ -907,7 +906,6 @@ if(ZLIB_FOUND)
   # Depend on ZLIB via imported targets. This allows our dependents to
   # get our dependencies transitively.
   list(APPEND CURL_LIBS ZLIB::ZLIB)
-  set_target_properties(ZLIB::ZLIB PROPERTIES INTERFACE_LIBCURL_PC_MODULES "zlib")
 endif()
 
 set(HAVE_BROTLI OFF)
@@ -2154,7 +2152,13 @@ if(NOT CURL_DISABLE_INSTALL)
       if(NOT _libname AND NOT _libs AND NOT _libdirs)
         message(WARNING "Bad lib in library list: ${_lib}")
       endif()
-      get_target_property(_modules "${_lib}" INTERFACE_LIBCURL_PC_MODULES)
+      if(_lib STREQUAL OpenSSL::SSL)
+        set(_modules "openssl")
+      elseif(_lib STREQUAL ZLIB::ZLIB)
+        set(_modules "zlib")
+      else()
+        get_target_property(_modules "${_lib}" INTERFACE_LIBCURL_PC_MODULES)
+      endif()
       if(_modules)
         list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "${_modules}")
       endif()