]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Rerun checks if compiler configuration changes
authorMatthias Maier <tamiko@43-1.org>
Sun, 6 May 2018 17:12:40 +0000 (12:12 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sun, 6 May 2018 17:19:14 +0000 (12:19 -0500)
cmake/checks/check_01_cpu_features.cmake
cmake/checks/check_01_cxx_features.cmake
cmake/checks/check_02_compiler_features.cmake
cmake/macros/macro_unset_if_changed.cmake [new file with mode: 0644]

index c133fa63354a21060aa40aca5285a4509b77aca4..1082e13b5438317b10a7a110fbca929c569e3f94 100644 (file)
@@ -68,16 +68,11 @@ ENDIF()
 
 IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
   #
-  # Take care that the following tests are rerun if CMAKE_REQUIRED_FLAGS
-  # changes..
+  # Take care that the following tests are rerun if the
+  # CMAKE_REQUIRED_FLAGS changes..
   #
-  IF(NOT "${CMAKE_REQUIRED_FLAGS}" STREQUAL "${DEAL_II_CHECK_CPU_FEATURES_SAVED}")
-    UNSET(DEAL_II_HAVE_SSE2 CACHE)
-    UNSET(DEAL_II_HAVE_AVX CACHE)
-    UNSET(DEAL_II_HAVE_AVX512 CACHE)
-  ENDIF()
-  SET(DEAL_II_CHECK_CPU_FEATURES_SAVED
-    "${CMAKE_REQUIRED_FLAGS}" CACHE INTERNAL "" FORCE
+  UNSET_IF_CHANGED(CHECK_CPU_FEATURES_FLAGS_SAVED "${CMAKE_REQUIRED_FLAGS}"
+    DEAL_II_HAVE_SSE2 DEAL_II_HAVE_AVX DEAL_II_HAVE_AVX512
     )
 
   CHECK_CXX_SOURCE_RUNS(
index 842bb034b861ed839ee8b1b416a6d87f54588491..f5581563f0fc6acd2340276bb85b54e64b7cfb4f 100644 (file)
@@ -477,6 +477,14 @@ ENDIF()
 #                                                                      #
 ########################################################################
 
+UNSET_IF_CHANGED(CHECK_CXX_FEATURES_FLAGS_SAVED
+  "${CMAKE_REQUIRED_FLAGS}${DEAL_II_CXX_VERSION_FLAG}${DEAL_II_WITH_CXX14}${DEAL_II_WITH_CXX17}"
+  DEAL_II_HAVE_ATTRIBUTE_FALLTHROUGH
+  DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE
+  DEAL_II_HAVE_FP_EXCEPTIONS
+  DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
+  )
+
 #
 # Try to enable a fallthrough attribute. This is a language feature in C++17,
 # but a compiler extension in earlier language versions: check both
index 9b25606212479729410a2b8ead30a4d8f050c318..098f77947c172c77a8a0fde53035fb415a948154 100644 (file)
 #   DEAL_II_COMPILER_HAS_FUSE_LD_GOLD
 #
 
+#
+# A couple of test results depend on compiler flags and the C++ mode. Rerun
+# these tests if necessary
+#
+
+UNSET_IF_CHANGED(CHECK_CXX_FEATURES_FLAGS_SAVED
+  "${CMAKE_REQUIRED_FLAGS}${DEAL_II_CXX_VERSION_FLAG}${DEAL_II_WITH_CXX14}${DEAL_II_WITH_CXX17}"
+  DEAL_II_COMPILER_HAS_CXX14_ATTRIBUTE_DEPRECATED
+  DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED
+  )
+
 
 #
 # Check whether the compiler allows to use arithmetic operations
diff --git a/cmake/macros/macro_unset_if_changed.cmake b/cmake/macros/macro_unset_if_changed.cmake
new file mode 100644 (file)
index 0000000..b87a5ee
--- /dev/null
@@ -0,0 +1,37 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2018 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# Usage:
+#   UNSET_IF_CHANGED(<internal variable> "string"
+#     [cached variable names]
+#     )
+#
+# This macro caches the supplied "string" internally in ${<internal
+# variable>} and unsets all supplied (cached) variables if this string
+# changes.
+#
+MACRO(UNSET_IF_CHANGED _variable _string)
+  IF(DEFINED ${_variable})
+    IF(NOT "${${_variable}}" STREQUAL "${_string}")
+      FOREACH(_arg ${ARGN})
+        MESSAGE(STATUS
+          "Configuration changed. Unsetting cached variable \"${_arg}\" and rerunning checks.")
+        UNSET(${_arg} CACHE)
+      ENDFOREACH()
+    ENDIF()
+  ENDIF()
+  SET(${_variable} "${_string}" CACHE INTERNAL "" FORCE)
+ENDMACRO()

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.