Skip to content

Commit 84c4669

Browse files
authored
build: set warning flags for each target instead of globally (#47)
1 parent b051aa8 commit 84c4669

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ cmake_minimum_required(VERSION 3.0)
22

33
project(example)
44

5-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wpedantic")
6-
75
add_library(example src/example.cpp)
86
target_include_directories(example PUBLIC include)
7+
target_compile_options(example PRIVATE -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wpedantic)
98

109
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
1110
include(cmake/CPM.cmake)
@@ -22,6 +21,7 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
2221

2322
add_executable(example_test test/example_test.cpp)
2423
target_link_libraries(example_test PRIVATE example Catch2::Catch2WithMain)
24+
target_compile_options(example_test PRIVATE -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wpedantic)
2525
catch_discover_tests(example_test)
2626
endif()
2727
endif()

0 commit comments

Comments
 (0)