From ee49f6bd9d2f88adb52e5a6422722e0b834bbaf6 Mon Sep 17 00:00:00 2001 From: Paul Dettorer Hervot Date: Wed, 16 Dec 2015 11:54:53 +0100 Subject: [PATCH] CMakeLists: add -Werror for linux/mac, ignore warnings on microprofile and nihstro and inhibit a faulty warning Inhibit clang's -Wtautological-constant-out-of-range-compare warning as static_casts may yield invalid values for enums that are still in the range of the underlying type, thus making the check not so tautological. It's a clang bug, see https://llvm.org/bugs/show_bug.cgi?id=16154 --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a0a161e7..ad33b4b2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,8 +64,15 @@ if (NOT DEFINED ARCHITECTURE) endif() message(STATUS "Target architecture: ${ARCHITECTURE}") +if (NOT CMAKE_GENERATOR STREQUAL Xcode) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") +endif() + if (NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wno-attributes -pthread") + # Currently, clang incorrectly throws this warning with enums, see https://llvm.org/bugs/show_bug.cgi?id=16154 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-tautological-constant-out-of-range-compare") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") if (ARCHITECTURE_x86_64) @@ -233,8 +240,8 @@ include_directories(${INI_PREFIX}) add_subdirectory(${INI_PREFIX}) add_subdirectory(externals/glad) -include_directories(externals/microprofile) -include_directories(externals/nihstro/include) +include_directories(SYSTEM externals/microprofile) # TODO: remove "SYSTEM" and actually fix the warnings upstream +include_directories(SYSTEM externals/nihstro/include) # TODO: remove "SYSTEM" and actually fix the warnings upstream if (MSVC) add_subdirectory(externals/getopt)