Skip to content

Commit

Permalink
allow controlling WALL and WERROR
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkreiser authored Nov 14, 2023
1 parent 6056135 commit 815e0ec
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ INCLUDE(GNUInstallDirs)
# Use a C++17 enabled compiler
set(CMAKE_CXX_STANDARD 17)

option(ENABLE_WALL "Convert compiler warnings to errors" ON)
option(ENABLE_WERROR "Convert compiler warnings to errors. Requires ENABLE_WALL" ON)

# What type of build
if(NOT MSVC_IDE) # TODO: May need to be extended for Xcode, CLion, etc.
if(NOT CMAKE_BUILD_TYPE)
Expand All @@ -29,10 +32,16 @@ else()
endif()

# Show all warnings and treat as errors
if(MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Wextra -pedantic -Werror)
if(MSVC AND ENABLE_WALL)
add_compile_options(/W4)
if(ENABLE_WERROR)
add_compile_options(/WX)
endif()
elseif(ENABLE_WALL)
add_compile_options(-Wall -Wextra -pedantic)
if(ENABLE_WERROR)
add_compile_options(-Werror)
endif()
endif()

option(ENABLE_SANITIZERS "Use all the integrated sanitizers for Debug build" OFF)
Expand Down

0 comments on commit 815e0ec

Please sign in to comment.