From 068bd8140923e4c1da8be5c7279b21080b234714 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sun, 6 May 2018 12:12:40 -0500 Subject: [PATCH] CMake: Rerun checks if compiler configuration changes --- cmake/checks/check_01_cpu_features.cmake | 13 ++----- cmake/checks/check_01_cxx_features.cmake | 8 ++++ cmake/checks/check_02_compiler_features.cmake | 11 ++++++ cmake/macros/macro_unset_if_changed.cmake | 37 +++++++++++++++++++ 4 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 cmake/macros/macro_unset_if_changed.cmake diff --git a/cmake/checks/check_01_cpu_features.cmake b/cmake/checks/check_01_cpu_features.cmake index c133fa6335..1082e13b54 100644 --- a/cmake/checks/check_01_cpu_features.cmake +++ b/cmake/checks/check_01_cpu_features.cmake @@ -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( diff --git a/cmake/checks/check_01_cxx_features.cmake b/cmake/checks/check_01_cxx_features.cmake index 842bb034b8..f5581563f0 100644 --- a/cmake/checks/check_01_cxx_features.cmake +++ b/cmake/checks/check_01_cxx_features.cmake @@ -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 diff --git a/cmake/checks/check_02_compiler_features.cmake b/cmake/checks/check_02_compiler_features.cmake index 9b25606212..098f77947c 100644 --- a/cmake/checks/check_02_compiler_features.cmake +++ b/cmake/checks/check_02_compiler_features.cmake @@ -38,6 +38,17 @@ # 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 index 0000000000..b87a5eeeec --- /dev/null +++ b/cmake/macros/macro_unset_if_changed.cmake @@ -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( "string" +# [cached variable names] +# ) +# +# This macro caches the supplied "string" internally in ${} 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() -- 2.39.5