File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,17 +2,12 @@ cmake_minimum_required(VERSION 3.0)
22
33project (error)
44
5- if (MSVC )
6- set (WARNING_FLAGS /WX /permissive- /W4 /w14640 /EHsc)
7- else ()
8- set (WARNING_FLAGS -WError -Wall -Wextra -Wnon-virtual-dtor -Wpedantic)
9- endif ()
10-
115include (cmake/CPM.cmake )
126
137if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR )
148 cpmaddpackage ("gh:TheLartians/Format.cmake@1.7.3" )
159 set (SUPPORT_TESTING TRUE )
10+ set (CHECK_WARNINGS TRUE )
1611endif ()
1712
1813if (SUPPORT_TESTING AND BUILD_TESTING)
@@ -33,11 +28,21 @@ cpmaddpackage("gh:fmtlib/fmt#10.0.0")
3328add_library (error src/error.cpp )
3429target_include_directories (error PUBLIC include )
3530target_link_libraries (error PUBLIC fmt )
36- target_compile_options (error PRIVATE ${WARNING_FLAGS} )
3731
3832if (SUPPORT_TESTING AND BUILD_TESTING)
3933 add_executable (error_test test /error_test.cpp )
4034 target_link_libraries (error_test PRIVATE error Catch2::Catch2WithMain )
41- target_compile_options (error_test PRIVATE ${WARNING_FLAGS} )
4235 catch_discover_tests (error_test )
4336endif ()
37+
38+ set (TARGETS error error_test)
39+ foreach (TARGET IN LISTS TARGETS)
40+ # Statically analyze code by checking for warnings.
41+ if (CHECK_WARNINGS)
42+ if (MSVC )
43+ target_compile_options (${TARGET} PRIVATE /WX /permissive- /W4 /w14640 /EHsc )
44+ else ()
45+ target_compile_options (${TARGET} PRIVATE -Werror -Wall -Wextra -Wnon-virtual-dtor -Wpedantic )
46+ endif ()
47+ endif ()
48+ endforeach ()
You can’t perform that action at this time.
0 commit comments