Commit 2d8e17c4f88efce80e274cb03eeb902e055a91d3
Committed by
GitHub
1 parent
66b52e6c
Add CMake option to not add warning flags (#267)
Allow extra compiler warnings to be disabled.
Showing
1 changed file
with
3 additions
and
0 deletions
CMakeLists.txt
| ... | ... | @@ -37,6 +37,7 @@ enable_testing() |
| 37 | 37 | option(CXXOPTS_BUILD_EXAMPLES "Set to ON to build examples" ON) |
| 38 | 38 | option(CXXOPTS_BUILD_TESTS "Set to ON to build tests" ON) |
| 39 | 39 | option(CXXOPTS_ENABLE_INSTALL "Generate the install target" ON) |
| 40 | +option(CXXOPTS_ENABLE_WARNINGS "Add warnings to CMAKE_CXX_FLAGS" ON) | |
| 40 | 41 | |
| 41 | 42 | # request c++11 without gnu extension for the whole project and enable more warnings |
| 42 | 43 | if (CXXOPTS_CXX_STANDARD) |
| ... | ... | @@ -47,11 +48,13 @@ endif() |
| 47 | 48 | |
| 48 | 49 | set(CMAKE_CXX_EXTENSIONS OFF) |
| 49 | 50 | |
| 51 | +if (CXXOPTS_ENABLE_WARNINGS) | |
| 50 | 52 | if(MSVC) |
| 51 | 53 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2") |
| 52 | 54 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| 53 | 55 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wshadow -Weffc++ -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion -Wsuggest-override") |
| 54 | 56 | endif() |
| 57 | +endif() | |
| 55 | 58 | |
| 56 | 59 | add_library(cxxopts INTERFACE) |
| 57 | 60 | add_library(cxxopts::cxxopts ALIAS cxxopts) | ... | ... |