From 97dc0ce15d038feb47a2f054cb53745c869e07c8 Mon Sep 17 00:00:00 2001 From: Dylan Kenneally Date: Thu, 21 Nov 2019 12:04:53 +1100 Subject: [PATCH] Added CMake option to set the compiler warning to max (-Wall /W4). Off by default --- Build.md | 1 + CMakeLists.txt | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Build.md b/Build.md index 2db47798d..4b7513313 100644 --- a/Build.md +++ b/Build.md @@ -77,6 +77,7 @@ The cmake-build-environment provides options to configure the build. The followi - **ASSIMP_BUILD_SAMPLES ( default OFF )**: If the official samples are built as well (needs Glut). - **ASSIMP_BUILD_TESTS ( default ON )**: If the test suite for Assimp is built in addition to the library. - **ASSIMP_COVERALLS ( default OFF )**: Enable this to measure test coverage. +- **ASSIMP_ERROR_MAX( default OFF)**: Enable all warnings. - **ASSIMP_WERROR( default OFF )**: Treat warnings as errors. - **ASSIMP_ASAN ( default OFF )**: Enable AddressSanitizer. - **ASSIMP_UBSAN ( default OFF )**: Enable Undefined Behavior sanitizer. diff --git a/CMakeLists.txt b/CMakeLists.txt index 693d6f16a..f69d2c9a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,10 @@ OPTION ( ASSIMP_COVERALLS "Enable this to measure test coverage." OFF ) +OPTION ( ASSIMP_ERROR_MAX + "Enable all warnings." + OFF +) OPTION ( ASSIMP_WERROR "Treat warnings as errors." OFF @@ -294,6 +298,16 @@ IF (ASSIMP_COVERALLS) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") ENDIF() +IF (ASSIMP_ERROR_MAX) + MESSAGE(STATUS "Turning on all warnings") + IF (MSVC) + ADD_COMPILE_OPTIONS(/W4) # NB: there is a /Wall option, pedantic mode + ELSE() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") + ENDIF() +ENDIF() + IF (ASSIMP_WERROR) MESSAGE(STATUS "Treating warnings as errors") IF (MSVC)