From: Matthias Maier Date: Tue, 23 May 2023 08:49:16 +0000 (-0500) Subject: CMake: fix copy_target_properties() for CMake versions prior to 3.19 X-Git-Tag: v9.5.0-rc1~200^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34960aed5f124b6056f0a6fd553f988ed493822c;p=dealii.git CMake: fix copy_target_properties() for CMake versions prior to 3.19 --- diff --git a/cmake/macros/macro_copy_target_properties.cmake b/cmake/macros/macro_copy_target_properties.cmake index 4834bf087f..0e589df1d3 100644 --- a/cmake/macros/macro_copy_target_properties.cmake +++ b/cmake/macros/macro_copy_target_properties.cmake @@ -52,9 +52,21 @@ function(copy_target_properties _destination_target) list(APPEND _processed_targets ${_entry}) message(STATUS " copying ${_entry} into ${_destination_target} ...") - get_target_property(_location ${_entry} IMPORTED_LOCATION) - if("${_location}" MATCHES "-NOTFOUND") - set(_location) + # + # Only query the LOCATION from non-interface libraries. An interface + # library is a CMake target that only consists of "INTERFACE" target + # properties and does not by itself refer to an executable or shared + # object/static archive. CMake prior to 3.19 will throw an error if we + # query for the LOCATION. Newer CMake versions simply return + # "-NOTFOUND". + # + set(_location) + get_target_property(_test ${_entry} TYPE) + if(NOT "${_test}" STREQUAL "INTERFACE_LIBRARY") + get_target_property(_location ${_entry} LOCATION) + if("${_location}" MATCHES "-NOTFOUND") + set(_location) + endif() endif() get_target_property(_values ${_entry} INTERFACE_LINK_LIBRARIES) @@ -73,7 +85,7 @@ function(copy_target_properties _destination_target) "of target »${_entry}«" ) endif() - list(APPEND _libraries ${_entry}) + list(APPEND _libraries ${_lib}) endif() endforeach()