From: Wolfgang Bangerth Date: Fri, 31 Jan 2025 16:45:52 +0000 (-0700) Subject: Move some code from source/ to cmake/config/. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F18064%2Fhead;p=dealii.git Move some code from source/ to cmake/config/. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e74da92e5..6a5e3eb51b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,9 +153,18 @@ endif() if(DEAL_II_HAVE_BUNDLED_DIRECTORY) add_subdirectory(bundled) endif() -add_subdirectory(source) # has to be included after bundled -add_subdirectory(cmake/config) # has to be included after source +# Now that we have collected information about the configuration +# and the bundled directory, set up the compilation of the +# library from the files in the source/ directory. +add_subdirectory(source) + +# Then also set up installation and other targets. +add_subdirectory(cmake/config) + +# Now also configure installation of the examples. This relies on +# the correctly set up library, so needs to come after configuration +# in source/ and cmake/config/ add_subdirectory(examples) add_subdirectory(contrib/utilities) diff --git a/cmake/config/CMakeLists.txt b/cmake/config/CMakeLists.txt index bd1aca2318..5ad6b6ce17 100644 --- a/cmake/config/CMakeLists.txt +++ b/cmake/config/CMakeLists.txt @@ -13,7 +13,7 @@ ## ------------------------------------------------------------------------ # -# This file sets up the project configuration consisting of +# This file sets up the project installation and configuration consisting of # # deal.IIConfig.cmake # deal.IIVersionConfig.cmake @@ -23,6 +23,38 @@ # two distinct setups. # + +message(STATUS "Setting up library installation") + +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 ${_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 +) + +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}::" + DESTINATION ${DEAL_II_PROJECT_CONFIG_RELDIR} + COMPONENT library + ) + +message(STATUS "Setting up library installation - Done") + + message(STATUS "Setting up project configuration") # diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index b5e6afc060..a82416c08a 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -207,34 +207,4 @@ foreach(build ${DEAL_II_BUILD_TYPES}) ) 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 ${_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 -) - -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}::" - DESTINATION ${DEAL_II_PROJECT_CONFIG_RELDIR} - COMPONENT library - ) - message(STATUS "Setting up library - Done")