From fb58b2325657b61ddae2d5373800076b468638f9 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 26 Feb 2026 12:35:51 +0100 Subject: [PATCH] cmake: fix confusing error when a dependency is undetected in `curl-config.cmake` Fixing: ``` CMake Error at /path/to/CURL/CURLConfig.cmake:190 (get_target_property): get_target_property() called with non-existent target "CURL::libssh2". ``` and replacing it with the clearer message: ``` CMake Error at /path/to/CURL/CURLTargets.cmake:61 (set_target_properties): The link interface of target "CURL::libcurl_static" contains: CURL::libssh2 but the target was not found. Possible reasons include: [...] ``` Reported-by: Val S. Ref: #20729 Follow-up to 16f073ef49f94412000218c9f6ad04e3fd7e4d01 #16973 Closes #20737 --- CMake/curl-config.in.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMake/curl-config.in.cmake b/CMake/curl-config.in.cmake index f4e17d29b3..62134cbcd8 100644 --- a/CMake/curl-config.in.cmake +++ b/CMake/curl-config.in.cmake @@ -176,9 +176,11 @@ if(TARGET @PROJECT_NAME@::@LIB_STATIC@) if(NOT _has_CMP0099 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.13 AND _curl_libs) set(_curl_libdirs "") foreach(_curl_lib IN LISTS _curl_libs) - get_target_property(_curl_libdir "${_curl_lib}" INTERFACE_LINK_DIRECTORIES) - if(_curl_libdir) - list(APPEND _curl_libdirs "${_curl_libdir}") + if(TARGET "${_curl_lib}") + get_target_property(_curl_libdir "${_curl_lib}" INTERFACE_LINK_DIRECTORIES) + if(_curl_libdir) + list(APPEND _curl_libdirs "${_curl_libdir}") + endif() endif() endforeach() if(_curl_libdirs)