]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Bugfix: set C++14 flag in CXX_FLAGS_SAVED 11331/head
authorMatthias Maier <tamiko@43-1.org>
Sun, 6 Dec 2020 19:25:34 +0000 (13:25 -0600)
committerMatthias Maier <tamiko@43-1.org>
Sun, 6 Dec 2020 20:01:37 +0000 (14:01 -0600)
When configuring we make an attempt to set the flag -std=c++14 if we
fail to detect C++14 support. Unfortunately, we accidentally set this
flag in DEAL_II_CXX_FLAGS instead of DEAL_II_CXX_FLAGS_SAVED.

This implied that RESET_CMAKE_REQUIRED() did not include the -std=c++14
flag and consequently compile tests that relied on C++14 support failed.

cmake/checks/check_01_cxx_features.cmake

index 556a22da3a7623aa023f6932a393b1e4276c2bbf..b75dd1ebae4b55c6306f6c6dfb7e0e63f460f0db 100644 (file)
 # tests. Create a small macro to easily set CMAKE_REQUIRED_FLAGS
 #
 MACRO(_set_up_cmake_required)
-  # Let's put the user supplied `DEAL_II_CXX_FLAGS_SAVED` last so that we
-  # never override a user supplied -std=c++XY flag in our tests.
   RESET_CMAKE_REQUIRED()
   SET(CMAKE_REQUIRED_FLAGS "")
-  ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_FLAGS}")
   ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_FLAGS_SAVED}")
+  ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_FLAGS}")
 ENDMACRO()
 
 
@@ -306,10 +304,17 @@ _set_up_cmake_required()
 _test_cxx14_support()
 
 IF(NOT DEAL_II_HAVE_CXX14)
-  MESSAGE(STATUS "C++14 support not available. Try to set -std=c++14 explicitly")
-  ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-std=c++14")
-  _set_up_cmake_required()
-  _test_cxx14_support()
+  #
+  # We failed to detect C++14 support. Let's make an attempt to set the
+  # -std= compiler flag. (But in order to minimize confusion let's not
+  # override any manually specified -std= variable set by the user.)
+  #
+  IF(NOT "${DEAL_II_CXX_FLAGS_SAVED}" MATCHES "-std=")
+    MESSAGE(STATUS "C++14 support not available. Try to set -std=c++14 explicitly")
+    ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_SAVED "-std=c++14")
+    _set_up_cmake_required()
+    _test_cxx14_support()
+  ENDIF()
 ENDIF()
 
 IF(NOT DEAL_II_HAVE_CXX14)

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.