]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: fix copy_target_properties() for CMake versions prior to 3.19
authorMatthias Maier <tamiko@43-1.org>
Tue, 23 May 2023 08:49:16 +0000 (03:49 -0500)
committerMatthias Maier <tamiko@43-1.org>
Tue, 23 May 2023 21:20:32 +0000 (16:20 -0500)
cmake/macros/macro_copy_target_properties.cmake

index 4834bf087f0eb909c2695a7bf894b296692f7f2e..0e589df1d31a640be2769888c648a7ea08d9e87c 100644 (file)
@@ -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()
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.