From: Matthias Maier Date: Sun, 28 Sep 2014 13:32:07 +0000 (+0200) Subject: CMake: Bugfix: Correctly detect unsupported flags in case of clang X-Git-Tag: v8.2.0-rc1~123^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50d09f5de342d515d9de22f2f07dbc8fe173d3d0;p=dealii.git CMake: Bugfix: Correctly detect unsupported flags in case of clang 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. --- diff --git a/cmake/checks/check_01_compiler_features.cmake b/cmake/checks/check_01_compiler_features.cmake index e9856af063..a1fc8c1ac3 100644 --- a/cmake/checks/check_01_compiler_features.cmake +++ b/cmake/checks/check_01_compiler_features.cmake @@ -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() diff --git a/cmake/macros/macro_enable_if_supported.cmake b/cmake/macros/macro_enable_if_supported.cmake index 325ae83ecd..198d90a8e3 100644 --- a/cmake/macros/macro_enable_if_supported.cmake +++ b/cmake/macros/macro_enable_if_supported.cmake @@ -22,6 +22,17 @@ # 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})