]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: enable -pedantic for language feature check
authorMatthias Maier <tamiko@43-1.org>
Thu, 30 Mar 2023 00:08:53 +0000 (19:08 -0500)
committerMatthias Maier <tamiko@43-1.org>
Thu, 30 Mar 2023 00:22:17 +0000 (19:22 -0500)
This is a funny one: gcc and clang silently accept the [[deprecated]]
and [[fallthrough]] attributes which are introduced in the C++17
standard - even when the compiler is configured only with C++14 support.

BUT, clang will issue a warning that the attributes are not supported if
compiled with -pedantic. Thus, we have to check for support of the
attributes with -pedantic set.

cmake/checks/check_01_cxx_features.cmake

index 4dc09a585040a972b8fbbf95bd438beff8b6f8d9..4a7319c79c2e07033fea7e109bd3fc826a0a9cbc 100644 (file)
@@ -365,12 +365,13 @@ _test_cxx20_support()
 #
 # Some compilers are too generous in accepting some of the language
 # features that we test below and do not issue an error but a warning. Set
-# -Werror to make the feature detection more reliable.
+# -pedantic -Werror to make the feature detection more reliable.
 #
 set(_werror_flag "")
 if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
   enable_if_supported(_werror_flag "/WX /EHsc")
 else()
+  enable_if_supported(_werror_flag "-pedantic")
   enable_if_supported(_werror_flag "-Werror")
   enable_if_supported(_werror_flag "-Wno-unused-command-line-argument")
 endif()

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.