From: Matthias Maier Date: Mon, 3 Jul 2023 15:03:54 +0000 (-0500) Subject: CMake: avoid updating deal.IIConfig.cmake when nothing changed X-Git-Tag: relicensing~773^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=180c1e9fa4215147a99b4422ba89c19e17fca382;p=dealii.git CMake: avoid updating deal.IIConfig.cmake when nothing changed --- diff --git a/cmake/config/CMakeLists.txt b/cmake/config/CMakeLists.txt index f66e213095..7a53edb4d9 100644 --- a/cmake/config/CMakeLists.txt +++ b/cmake/config/CMakeLists.txt @@ -87,6 +87,56 @@ foreach(_build ${DEAL_II_BUILD_TYPES}) list(APPEND CONFIG_TARGET ${_keyword} \${DEAL_II_TARGET_${_build}}) endforeach() +# +# Collect feature configuration that will be added to the configuration files: +# + +set(FEATURE_CONFIGURATION_STRING " +# +# Feature configuration: +# + +set(DEAL_II_WITH_CXX11 ON) +set(DEAL_II_WITH_CXX14 ON) +set(DEAL_II_WITH_CXX17 ON) +set(DEAL_II_WITH_CXX20 ${DEAL_II_HAVE_CXX20}) +set(DEAL_II_WITH_THREADS ON)\n" + ) + +set(_additional_config_variables) +get_cmake_property(_res VARIABLES) +foreach(_var ${_res}) + if(_var MATCHES "DEAL_II_.*(WITH|FEATURE.*BUNDLED)") + list(APPEND _additional_config_variables ${_var}) + endif() +endforeach() + +set(_deal_ii_features_sorted ${DEAL_II_FEATURES}) +list(SORT _deal_ii_features_sorted) +foreach(_name ${_deal_ii_features_sorted}) + set(_var DEAL_II_WITH_${_name}) + + string(APPEND FEATURE_CONFIGURATION_STRING "set(${_var} ${${_var}})\n") + # + # Do not pollute deal.IIConfig.cmake with package details of + # unconfigured features. + # + if(${_var}) + if(NOT "${${_name}_VERSION}" STREQUAL "") + string(APPEND FEATURE_CONFIGURATION_STRING + "set(DEAL_II_${_name}_VERSION \"${${_name}_VERSION}\")\n" + ) + endif() + foreach(_additional ${_additional_config_variables}) + if(_additional MATCHES "(DEAL_II_${_name}_WITH|DEAL_II_FEATURE_${_name})") + string(APPEND FEATURE_CONFIGURATION_STRING + "set(${_additional} ${${_additional}})\n" + ) + endif() + endforeach() + endif() +endforeach() + # # For binary dir: # @@ -127,59 +177,6 @@ install(FILES COMPONENT library ) -# -# Append feature configuration to all configuration files: -# - -set(_files - ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake - ) -foreach(_file ${_files}) - file(APPEND ${_file} "\n\n#\n# Feature configuration:\n#\n\n") - file(APPEND ${_file} - "set(DEAL_II_WITH_CXX11 ON)\n" - "set(DEAL_II_WITH_CXX14 ON)\n" - "set(DEAL_II_WITH_CXX17 ON)\n" - "set(DEAL_II_WITH_CXX20 ${DEAL_II_HAVE_CXX20})\n" - "set(DEAL_II_WITH_THREADS ON)\n" - ) -endforeach() - -get_cmake_property(_res VARIABLES) -foreach(_var ${_res}) - if(_var MATCHES "DEAL_II_.*(WITH|FEATURE.*BUNDLED)") - list(APPEND _additional_config_variables ${_var}) - endif() -endforeach() - -set(_deal_ii_features_sorted ${DEAL_II_FEATURES}) -list(SORT _deal_ii_features_sorted) -foreach(_name ${_deal_ii_features_sorted}) - set(_var DEAL_II_WITH_${_name}) - - foreach(_file ${_files}) - file(APPEND ${_file} "set(${_var} ${${_var}})\n") - # - # Do not pollute deal.IIConfig.cmake with package details of - # unconfigured features. - # - if(${_var}) - if(NOT "${${_name}_VERSION}" STREQUAL "") - file(APPEND ${_file} - "set(DEAL_II_${_name}_VERSION \"${${_name}_VERSION}\")\n" - ) - endif() - - foreach(_additional ${_additional_config_variables}) - if(_additional MATCHES "(DEAL_II_${_name}_WITH|DEAL_II_FEATURE_${_name})") - file(APPEND ${_file} "set(${_additional} ${${_additional}})\n") - endif() - endforeach() - endif() - endforeach() -endforeach() - # # Job's done. # diff --git a/cmake/config/Config.cmake.in b/cmake/config/Config.cmake.in index 2c1cc2c3d3..e88093e927 100644 --- a/cmake/config/Config.cmake.in +++ b/cmake/config/Config.cmake.in @@ -185,3 +185,5 @@ set(DEAL_II_TARGET_RELEASE "@CONFIG_TARGET_RELEASE@") # Full list of targets with "debug" and "optimized" keywords for easy use with TARGET_LINK_LIBRARIES: set(DEAL_II_TARGET "@CONFIG_TARGET@") + +@FEATURE_CONFIGURATION_STRING@