From 0a2502cfabc2b3e851b4ee7a3d13371dcb0e0d39 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Tue, 13 Jun 2023 21:19:49 +0200 Subject: [PATCH] CMake: Improve finding library name or path of imported targets Checking LOCATION{_CONFIG} property on interfaces is only supported since CMake 3.19. Also check the LOCATION and IMPORTED_LIBNAME properties for possible library locations. See #23632. (cherry picked from commit 0f1f61a9c8c9fc8c4cb81a380df157e8171b0712) --- build/cmake/config.cmake | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/build/cmake/config.cmake b/build/cmake/config.cmake index 53d545388e..c68a1aa494 100644 --- a/build/cmake/config.cmake +++ b/build/cmake/config.cmake @@ -40,14 +40,25 @@ macro(wx_get_dependencies var lib) else() get_target_property(dep_name ${dep} OUTPUT_NAME) endif() - if(NOT dep_name) - # imported target + + # imported target + if(CMAKE_VERSION VERSION_GREATER "3.18") + # CMake <= 3.18 only allows a few properties to be checked, not LOCATION, see + # https://cmake.org/cmake/help/v3.18/manual/cmake-buildsystem.7.html#interface-libraries set(prop_suffix) if (CMAKE_BUILD_TYPE) string(TOUPPER "${CMAKE_BUILD_TYPE}" prop_suffix) set(prop_suffix "_${prop_suffix}") endif() - get_target_property(dep_name ${dep} LOCATION${prop_suffix}) + if(NOT dep_name AND prop_suffix) + get_target_property(dep_name ${dep} LOCATION${prop_suffix}) + endif() + if(NOT dep_name) + get_target_property(dep_name ${dep} LOCATION) + endif() + endif() + if(NOT dep_name) + get_target_property(dep_name ${dep} IMPORTED_LIBNAME) endif() else() # For the value like $<$:LIB_PATH>