]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: try to filter generator expression in copy_target_properties()
authorMatthias Maier <tamiko@43-1.org>
Tue, 23 May 2023 12:17:50 +0000 (07:17 -0500)
committerMatthias Maier <tamiko@43-1.org>
Tue, 23 May 2023 21:20:32 +0000 (16:20 -0500)
As long as the generator expressions are not too complicated we can
simply remove them.

If any of the upstream project starts to use more complex generator
expressions we will at some point have to abandon our approach of
copying target properties.

cmake/macros/macro_copy_target_properties.cmake
cmake/macros/macro_strip_known_generator_expressions.cmake [new file with mode: 0644]

index 0e589df1d31a640be2769888c648a7ea08d9e87c..c9b62b21b254c64386f2a22e543ff9490ff9ac9e 100644 (file)
@@ -75,6 +75,7 @@ function(copy_target_properties _destination_target)
     endif()
 
     foreach(_lib ${_location} ${_values})
+      strip_known_generator_expressions(_lib)
       if(TARGET ${_lib})
         list(APPEND _source_targets ${_lib})
       else()
diff --git a/cmake/macros/macro_strip_known_generator_expressions.cmake b/cmake/macros/macro_strip_known_generator_expressions.cmake
new file mode 100644 (file)
index 0000000..25ccef8
--- /dev/null
@@ -0,0 +1,26 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2023 - 2023 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE.md at
+## the top level directory of deal.II.
+##
+## ---------------------------------------------------------------------
+
+#
+# strip_known_generator_expressions(<variable>)
+#
+# Strip an enclosing generator expression from the variable. This macro is
+# primarily used in copy_target_properties
+#
+
+macro(strip_known_generator_expressions _variable)
+  string(REGEX REPLACE "^\\$<LINK_ONLY:(.*)>$" "\\1" ${_variable} "${${_variable}}")
+endmacro()
+

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.