]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Bugfix: Correctly detect unsupported flags in case of clang
authorMatthias Maier <tamiko@kyomu.43-1.org>
Sun, 28 Sep 2014 13:32:07 +0000 (15:32 +0200)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Sun, 28 Sep 2014 13:40:33 +0000 (15:40 +0200)
The clang compiler frontend is very conservative in not issuing an error
for unsupported compile flags but that are valid for gcc. Therefore, also
supply "-Werror" for the clang compiler in all 'ENABLE_IF_SUPPORTED' tests.

cmake/checks/check_01_compiler_features.cmake
cmake/macros/macro_enable_if_supported.cmake

index e9856af06385fa1f93990f1fbf508a09a9fab7e3..a1fc8c1ac36174137295a00683a8c454298b0c58 100644 (file)
@@ -1,6 +1,6 @@
 ## ---------------------------------------------------------------------
 ##
-## Copyright (C) 2012 - 2013 by the deal.II authors
+## Copyright (C) 2012 - 2014 by the deal.II authors
 ##
 ## This file is part of the deal.II library.
 ##
@@ -152,7 +152,7 @@ CHECK_CXX_SOURCE_COMPILES(
   HAVE_GLIBC_STACKTRACE)
 
 IF(HAVE_GLIBC_STACKTRACE AND NOT DEAL_II_STATIC_EXECUTABLE)
-  ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-rdynamic")
+  ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-rdynamic")
 ENDIF()
 
 
index 325ae83ecd0184a00631902f5ea90b4770816787..198d90a8e39afe86eaccbfbfc5b843cd827501e4 100644 (file)
 #
 
 MACRO(ENABLE_IF_SUPPORTED _variable _flag)
+  #
+  # Clang is too conservative when reporting unsupported compiler flags.
+  # Therefore, we promote all warnings for an unsupported compiler flag to
+  # actual errors with the -Werror switch:
+  #
+  IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+    SET(_werror_string "-Werror ")
+  ELSE()
+    SET(_werror_string "")
+  ENDIF()
+
   STRING(STRIP "${_flag}" _flag_stripped)
   IF(NOT "${_flag_stripped}" STREQUAL "")
     STRING(REGEX REPLACE "^-" "" _flag_name "${_flag_stripped}")
@@ -29,7 +40,7 @@ MACRO(ENABLE_IF_SUPPORTED _variable _flag)
     STRING(REPLACE "-" "_" _flag_name "${_flag_name}")
     STRING(REPLACE "++" "__" _flag_name "${_flag_name}")
     CHECK_CXX_COMPILER_FLAG(
-      "${_flag_stripped}"
+      "${_werror_string}${_flag_stripped}"
       DEAL_II_HAVE_FLAG_${_flag_name}
       )
     IF(DEAL_II_HAVE_FLAG_${_flag_name})

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.