From dfa8307e813c7ae53d4dbbaa20b7703b750d5ae3 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 23 Aug 2019 23:18:40 +0200 Subject: [PATCH] Add warning flags also for clang --- CMakeLists.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e2670c13..ec72710a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2352,14 +2352,14 @@ endif() ################################################################################ # Set compiler flags ################################################################################ +set(CXX_WARNING_FLAGS -Wall -Wextra) if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) # Add warning flags # For "-Wall" see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html - set(cxx_warning_flags -Wall -Wextra) if(NOT (CMAKE_VERSION VERSION_LESS "3.3")) - add_compile_options("$<$:${cxx_warning_flags}>") + add_compile_options("$<$:${CXX_WARNING_FLAGS}>") else() - add_compile_options("$<$,CXX>:${cxx_warning_flags}>") + add_compile_options("$<$,CXX>:${CXX_WARNING_FLAGS}>") endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") add_compile_options(-Wno-missing-field-initializers) @@ -2368,6 +2368,13 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) add_compile_options(-Wno-psabi) endif() endif() +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(NOT (CMAKE_VERSION VERSION_LESS "3.3")) + add_compile_options("$<$:${CXX_WARNING_FLAGS}>") + else() + add_compile_options("$<$,CXX>:${CXX_WARNING_FLAGS}>") + endif() +endif() # Processor-architecture related flags # See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html