]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: fix "Release" and "Debug" only configure for CMake 3.30 17217/head
authorMatthias Maier <tamiko@43-1.org>
Fri, 5 Jul 2024 22:52:04 +0000 (17:52 -0500)
committerMatthias Maier <tamiko@43-1.org>
Fri, 5 Jul 2024 22:56:20 +0000 (17:56 -0500)
Beginning with version 3.30 CMake makes it an error to specify a
nonexistent target in a call to target_link_libraries() even if that
target is never used internally and only part of the exported interface.
This is a problem as we want to add configuration dependent targets with
a generator expression that are later exported:

  $<$<CONFIG:Release>:dealii::dealii_release> (...)

Note that we cannot simply use $<$<CONFIG:Release>:dealii_release> as
CMake then does not complete "dealii_release" to "dealii::dealii_release"
upon target export...

As a workaround we create alias targets with the "dealii::" namespace,
which makes the call to target_link_libraries() succeed.

source/CMakeLists.txt

index 3354b4c5ac89b2a096e8a8eb2ef7b0120d763e26..161dafe9b59219068f16ff587a24b59a8495e7d1 100644 (file)
@@ -190,6 +190,17 @@ foreach(build ${DEAL_II_BUILD_TYPES})
       )
   endif()
 
+  if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.30")
+    #
+    # Create alias targets "dealii::dealii_release" and "dealii::dealii_debug"
+    # to have the exported target names available when populating the link
+    # interface for our "dealii::dealii" convenience target:
+    #
+    add_library(${DEAL_II_TARGET_NAME}::${DEAL_II_TARGET_NAME}_${build_lowercase}
+      ALIAS ${DEAL_II_TARGET_NAME}_${build_lowercase}
+      )
+  endif()
+
   target_link_libraries(${DEAL_II_TARGET_NAME} INTERFACE
     "$<$<CONFIG:${build_camelcase}>:${DEAL_II_TARGET_NAME}::${DEAL_II_TARGET_NAME}_${build_lowercase}>"
     )

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.