]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Bugfix: Properly fix (CMAKE|DEAL_II)_CXX_FLAGS* caching 2822/head
authorMatthias Maier <tamiko@43-1.org>
Wed, 13 Jul 2016 12:57:28 +0000 (07:57 -0500)
committerMatthias Maier <tamiko@43-1.org>
Thu, 14 Jul 2016 08:18:54 +0000 (03:18 -0500)
Well, #2793 did not really solve the problem.

This commit reorganizes the caching process entirely:

 * always store CMAKE_* variables in internal cache

 * do not force update cached DEAL_II_* variables

 * fix the issue of simultaneous usage of CMAKE_* and DEAL_II_* variables
   by prepending DEAL_II_* variables *after* the cache setup

cmake/setup_cached_variables.cmake
doc/news/changes.h

index 28881b719981ae7ab29aa344f004d398aecf6792..3bbd7c1e0bb67aab56339a52aa02aef9ca2b2738 100644 (file)
@@ -104,7 +104,7 @@ OPTION(DEAL_II_FORCE_AUTODETECTION
 
 ########################################################################
 #                                                                      #
-#                       Compilation and linking:                       #
+#           Configuration options for Compilation and linking:         #
 #                                                                      #
 ########################################################################
 
@@ -183,27 +183,11 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH "ON" CACHE BOOL
 MARK_AS_ADVANCED(CMAKE_INSTALL_RPATH_USE_LINK_PATH)
 
 
-#
-# Translate CMake specific variables to deal.II naming:
-#
-
-FOREACH(_flag CXX_FLAGS CXX_FLAGS_RELEASE CXX_FLAGS_DEBUG)
-  IF(NOT "${CMAKE_${_flag}}" STREQUAL "")
-    MESSAGE(STATUS
-      "Prepending \${CMAKE_${_flag}} to \${DEAL_II_${_flag}}"
-      )
-    SET(DEAL_II_${_flag} "${CMAKE_${_flag}} ${DEAL_II_${_flag}}")
-  ENDIF()
-ENDFOREACH()
-
-FOREACH(_flag LINKER_FLAGS LINKER_FLAGS_DEBUG LINKER_FLAGS_RELEASE)
-  IF(NOT "${CMAKE_SHARED_${_flag}}" STREQUAL "")
-    MESSAGE(STATUS
-      "Prepending \${CMAKE_SHARED_${_flag}} to \${DEAL_II_${_flag}}"
-      )
-    SET(DEAL_II_${_flag} "${CMAKE_${_flag}} ${DEAL_II_${_flag}}")
-  ENDIF()
-ENDFOREACH()
+########################################################################
+#                                                                      #
+#                       Compilation and linking:                       #
+#                                                                      #
+########################################################################
 
 #
 # Hide all unused CMake variables:
@@ -232,12 +216,13 @@ SET(DEAL_II_REMOVED_FLAGS
   CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
   )
 FOREACH(_flag ${DEAL_II_REMOVED_FLAGS})
-  # Go away...
+  #
+  # Promote all variables to internal cache. This prevents CMake from
+  # populating these variables with default values. Further, store the
+  # actual content of the variables such that users can still use
+  # CMAKE_CXX_FLAGS(|_RELEASE|_DEBUG).
+  #
   SET(${_flag} ${${_flag}} CACHE INTERNAL "" FORCE)
-  # Also set it to an empty string for the configuration run so that it
-  # does not confuse the build system (to unset is not an option - it is
-  # cached...)
-  SET(${_flag} "")
 ENDFOREACH()
 
 #
@@ -253,15 +238,51 @@ SET(DEAL_II_USED_FLAGS
   DEAL_II_LINKER_FLAGS_RELEASE
   )
 FOREACH(_flag ${DEAL_II_USED_FLAGS})
-  #
-  # Promote to cache:
-  #
   SET(${_flag} "${${_flag}}" CACHE STRING
     "The user supplied cache variable will be appended _at the end_ of the configuration step to the auto generated ${_flag} variable"
-    FORCE
     )
   MARK_AS_ADVANCED(${_flag})
+ENDFOREACH()
+
+FOREACH(_variable
+  DEAL_II_DEFINITIONS
+  DEAL_II_DEFINITIONS_DEBUG
+  DEAL_II_DEFINITIONS_RELEASE
+  )
+  SET(${_variable} ${${_variable}} CACHE STRING
+    "Additional, user supplied compile definitions"
+    )
+  MARK_AS_ADVANCED(${_variable})
+ENDFOREACH()
+
+#
+# Translate CMake specific variables to deal.II naming:
+#
+
+FOREACH(_flag CXX_FLAGS CXX_FLAGS_RELEASE CXX_FLAGS_DEBUG)
+  IF(NOT "${CMAKE_${_flag}}" STREQUAL "")
+    MESSAGE(STATUS
+      "Prepending \${CMAKE_${_flag}} to \${DEAL_II_${_flag}}"
+      )
+    SET(DEAL_II_${_flag} "${CMAKE_${_flag}} ${DEAL_II_${_flag}}")
+  ENDIF()
+ENDFOREACH()
+
+FOREACH(_flag LINKER_FLAGS LINKER_FLAGS_DEBUG LINKER_FLAGS_RELEASE)
+  IF(NOT "${CMAKE_SHARED_${_flag}}" STREQUAL "")
+    MESSAGE(STATUS
+      "Prepending \${CMAKE_SHARED_${_flag}} to \${DEAL_II_${_flag}}"
+      )
+    SET(DEAL_II_${_flag} "${CMAKE_${_flag}} ${DEAL_II_${_flag}}")
+  ENDIF()
+ENDFOREACH()
+
+#
+# Store user supplied flags in ${_flag}_SAVED and clear configuration
+# variables.
+#
 
+FOREACH(_flag ${DEAL_II_USED_FLAGS})
   #
   # The order of compiler and linker flags is important. In order to
   # provide an override mechanism we have to save the initial (cached)
@@ -274,21 +295,15 @@ FOREACH(_flag ${DEAL_II_USED_FLAGS})
   SET(${_flag} "")
 ENDFOREACH()
 
-FOREACH(_variable
-  DEAL_II_DEFINITIONS
-  DEAL_II_DEFINITIONS_DEBUG
-  DEAL_II_DEFINITIONS_RELEASE
-  )
-  #
-  # Promote to cache:
-  #
-  SET(${_variable} ${${_variable}} CACHE STRING
-    "Additional, user supplied compile definitions"
-    )
-  MARK_AS_ADVANCED(${_variable})
+#
+# Also set all unused CMAKE_* flags to an empty string for the
+# configuration run so that it does not confuse the build system (to unset
+# is not an option - it is cached...)
+#
+FOREACH(_flag ${DEAL_II_REMOVED_FLAGS})
+  SET(${_flag} "")
 ENDFOREACH()
 
-
 #
 # Finally, read in CXXFLAGS and LDFLAGS from environment and prepend them
 # to the saved variables:
@@ -296,6 +311,7 @@ ENDFOREACH()
 # Also strip leading and trailing whitespace from linker flags to make
 # old cmake versions happy
 #
+
 SET(DEAL_II_CXX_FLAGS_SAVED "$ENV{CXXFLAGS} ${DEAL_II_CXX_FLAGS_SAVED}")
 STRING(STRIP "${DEAL_II_CXX_FLAGS_SAVED}" DEAL_II_CXX_FLAGS_SAVED)
 SET(DEAL_II_LINKER_FLAGS_SAVED "$ENV{LDFLAGS} ${DEAL_II_LINKER_FLAGS_SAVED}")
index b62949bd57eca29460bcc157f8357ac13ebd546e..fe3edfa31f9758fbac888facfb652bd05a23359d 100644 (file)
@@ -365,8 +365,15 @@ inconvenience this causes.
    "-fuse-ld=gold" linker flag if openmpi is incompatible with it.
  <br>
  (Wolfgang Bangerth, Martin Kronbichler, Matthias Maier, 2016/07/13)
+ </li>
 
+ <li> Fixed: CMake now handles mixed compiler and linker setup via
+ <code>DEAL_II_CXX_FLAGS*</code> / <code>DEAL_II_LINKER_FLAGS*</code> and
+ <code>CMAKE_CXX_FLAGS*</code> properly.
+ <br>
+ (Matthias Maier, 2016/07/13)
  </li>
+
  <li> Fixed: FEValues::reinit() would sometimes try to be overly
  clever and not re-compute information when called with the same
  cell twice in a row, even if the underlying triangulation had

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.