From 772cef40fc798fdb531af637257b8da9838f27c9 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 29 Mar 2023 19:08:53 -0500 Subject: [PATCH] CMake: enable -pedantic for language feature check 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/checks/check_01_cxx_features.cmake b/cmake/checks/check_01_cxx_features.cmake index 4dc09a5850..4a7319c79c 100644 --- a/cmake/checks/check_01_cxx_features.cmake +++ b/cmake/checks/check_01_cxx_features.cmake @@ -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() -- 2.39.5