From: Matthias Maier Date: Fri, 5 Jul 2024 22:52:04 +0000 (-0500) Subject: CMake: fix "Release" and "Debug" only configure for CMake 3.30 X-Git-Tag: v9.6.0-rc1~129^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F17217%2Fhead;p=dealii.git CMake: fix "Release" and "Debug" only configure for CMake 3.30 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: $<$:dealii::dealii_release> (...) Note that we cannot simply use $<$: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. --- diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 3354b4c5ac..161dafe9b5 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -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 "$<$:${DEAL_II_TARGET_NAME}::${DEAL_II_TARGET_NAME}_${build_lowercase}>" )