]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: avoid updating deal.IIConfig.cmake when nothing changed
authorMatthias Maier <tamiko@43-1.org>
Mon, 3 Jul 2023 15:03:54 +0000 (10:03 -0500)
committerMatthias Maier <tamiko@43-1.org>
Mon, 3 Jul 2023 15:27:31 +0000 (10:27 -0500)
cmake/config/CMakeLists.txt
cmake/config/Config.cmake.in

index f66e2130959423acb4488c463b350cf2800e3d5f..7a53edb4d9b3e1cff67a2d769ef768d8206af672 100644 (file)
@@ -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.
 #
index 2c1cc2c3d3ba96f0f7ac4059593092f20bfd6e44..e88093e92791de1ff06c05ca7e5d5a5f0ec3c8d4 100644 (file)
@@ -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@

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.