From: Matthias Maier Date: Sun, 6 May 2018 17:12:40 +0000 (-0500) Subject: CMake: Rerun checks if compiler configuration changes X-Git-Tag: v9.0.0-rc3~3^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbbabb89a428d02264227f5a3616f4717074042a;p=dealii.git CMake: Rerun checks if compiler configuration changes --- 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 827766a8fa..50203fc7e5 100644 --- a/cmake/checks/check_01_cxx_features.cmake +++ b/cmake/checks/check_01_cxx_features.cmake @@ -474,6 +474,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()