File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -2,17 +2,12 @@ cmake_minimum_required(VERSION 3.0)
2
2
3
3
project (error )
4
4
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
-
11
5
include (cmake/CPM.cmake )
12
6
13
7
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR )
14
8
cpmaddpackage ("gh:TheLartians/Format.cmake@1.7.3" )
15
9
set (SUPPORT_TESTING TRUE )
10
+ set (CHECK_WARNINGS TRUE )
16
11
endif ()
17
12
18
13
if (SUPPORT_TESTING AND BUILD_TESTING )
@@ -33,11 +28,21 @@ cpmaddpackage("gh:fmtlib/fmt#10.0.0")
33
28
add_library (error src/error.cpp )
34
29
target_include_directories (error PUBLIC include )
35
30
target_link_libraries (error PUBLIC fmt )
36
- target_compile_options (error PRIVATE ${WARNING_FLAGS} )
37
31
38
32
if (SUPPORT_TESTING AND BUILD_TESTING )
39
33
add_executable (error_test test /error_test.cpp )
40
34
target_link_libraries (error_test PRIVATE error Catch2::Catch2WithMain )
41
- target_compile_options (error_test PRIVATE ${WARNING_FLAGS} )
42
35
catch_discover_tests (error_test )
43
36
endif ()
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