]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: simplify Target.config generation 15617/head
authorMatthias Maier <tamiko@43-1.org>
Mon, 3 Jul 2023 15:23:32 +0000 (10:23 -0500)
committerMatthias Maier <tamiko@43-1.org>
Mon, 3 Jul 2023 15:27:31 +0000 (10:27 -0500)
Let us call the export(TARGETS ...) function at one central place. This
simplifies the configuration logic significantly and avoids accidentally
recreating the file.

cmake/macros/macro_define_interface_target.cmake
cmake/setup_finalize.cmake
source/CMakeLists.txt

index c9f74ad5665b7dfe267e4ed8e591ae6c72461313..54d1b295850448f6259662099b16e4bf9177ddca 100644 (file)
@@ -146,17 +146,6 @@ function(define_interface_target _feature)
       copy_target_properties(${_interface_target} ${${_feature}_TARGETS} ${${_feature}_TARGETS_${_build}})
     endif()
 
-    export(TARGETS ${_interface_target}
-      NAMESPACE "${DEAL_II_TARGET_NAME}::"
-      FILE ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake
-      APPEND
-      )
-
-    install(TARGETS ${_interface_target}
-      COMPONENT library
-      EXPORT ${DEAL_II_PROJECT_CONFIG_NAME}Targets
-      )
-
     if(${_feature}_SPLIT_CONFIGURATION)
       # Future FIXME: change to block(PARENT_SCOPE)/endblock() (CMake 3.25)
       list(APPEND DEAL_II_TARGETS_${_build} ${_interface_target})
index 4fbfd19c0cfcb3782cdf5c1df23b01eabb4d4b54..f39c09c420f98b30e229c42c726caff4449d7386 100644 (file)
@@ -50,16 +50,6 @@ foreach(_flag ${DEAL_II_REMOVED_FLAGS})
   endif()
 endforeach()
 
-
-#
-# Clean up deal.IITargets.cmake in the build directory:
-#
-
-file(REMOVE
-  ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake
-  )
-
-
 ########################################################################
 #                                                                      #
 #                Query for git repository information:                 #
index eda829e9707300d02eb7b23ee4e8952050e1db13..f99c27fb0f0bd76d65d77e49b98ceeff28c69b9a 100644 (file)
@@ -191,40 +191,34 @@ foreach(build ${DEAL_II_BUILD_TYPES})
       )
   endif()
 
-  file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR})
-  export(TARGETS ${DEAL_II_TARGET_NAME}_${build_lowercase}
-    NAMESPACE "${DEAL_II_TARGET_NAME}::"
-    FILE ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake
-    APPEND
-    )
-
-  install(TARGETS ${DEAL_II_TARGET_NAME}_${build_lowercase}
-    COMPONENT library
-    EXPORT ${DEAL_II_PROJECT_CONFIG_NAME}Targets
-    RUNTIME DESTINATION ${DEAL_II_EXECUTABLE_RELDIR}
-    LIBRARY DESTINATION ${DEAL_II_LIBRARY_RELDIR}
-    ARCHIVE DESTINATION ${DEAL_II_LIBRARY_RELDIR}
-    )
-
   target_link_libraries(${DEAL_II_TARGET_NAME} INTERFACE
     "$<$<CONFIG:${build_camelcase}>:${DEAL_II_TARGET_NAME}::${DEAL_II_TARGET_NAME}_${build_lowercase}>"
     )
 endforeach()
 
+#
+# And install all targets:
+#
+
+set(_targets ${DEAL_II_TARGET_NAME})
+foreach(build ${DEAL_II_BUILD_TYPES})
+  string(TOLOWER ${build} build_lowercase)
+  list(APPEND _targets ${DEAL_II_TARGET_NAME}_${build_lowercase})
+endforeach()
+
 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR})
-export(TARGETS ${DEAL_II_TARGET_NAME}
+export(TARGETS ${_targets} ${DEAL_II_TARGETS} ${DEAL_II_TARGETS_DEBUG} ${DEAL_II_TARGETS_RELEASE}
   NAMESPACE "${DEAL_II_TARGET_NAME}::"
   FILE ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake
-  APPEND
 )
 
-install(TARGETS ${DEAL_II_TARGET_NAME}
+install(TARGETS ${_targets} ${DEAL_II_TARGETS} ${DEAL_II_TARGETS_DEBUG} ${DEAL_II_TARGETS_RELEASE}
   COMPONENT library
   EXPORT ${DEAL_II_PROJECT_CONFIG_NAME}Targets
   RUNTIME DESTINATION ${DEAL_II_EXECUTABLE_RELDIR}
   LIBRARY DESTINATION ${DEAL_II_LIBRARY_RELDIR}
   ARCHIVE DESTINATION ${DEAL_II_LIBRARY_RELDIR}
-)
+  )
 
 install(EXPORT ${DEAL_II_PROJECT_CONFIG_NAME}Targets
   NAMESPACE "${DEAL_II_TARGET_NAME}::"

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.