Skip to content

Commit 170d21e

Browse files
authored
build: use CheckWarning.cmake to check for compiler warnings (#52)
1 parent cb1be5b commit 170d21e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ cmake_minimum_required(VERSION 3.0)
22

33
project(example)
44

5+
include(cmake/CPM.cmake)
6+
cpmusepackagelock(package-lock)
7+
8+
cpmgetpackage(CheckWarning.cmake)
9+
510
add_library(example src/example.cpp)
611
target_include_directories(example PUBLIC include)
7-
target_compile_options(example PRIVATE -Werror -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wpedantic)
12+
target_check_warning(example)
813

914
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
10-
include(cmake/CPM.cmake)
11-
cpmusepackagelock(package-lock)
1215
cpmgetpackage(Format.cmake)
1316

1417
if(BUILD_TESTING)
@@ -21,7 +24,7 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
2124

2225
add_executable(example_test test/example_test.cpp)
2326
target_link_libraries(example_test PRIVATE example Catch2::Catch2WithMain)
24-
target_compile_options(example_test PRIVATE -Werror -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wpedantic)
27+
target_check_warning(example_test)
2528
catch_discover_tests(example_test)
2629
endif()
2730
endif()

package-lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# CPM Package Lock
22
# This file should be committed to version control
33

4+
# CheckWarning.cmake
5+
CPMDeclarePackage(CheckWarning.cmake
6+
VERSION 1.0.0
7+
GITHUB_REPOSITORY threeal/CheckWarning.cmake
8+
SYSTEM YES
9+
EXCLUDE_FROM_ALL YES
10+
)
411
# Format.cmake
512
CPMDeclarePackage(Format.cmake
613
VERSION 1.7.3

0 commit comments

Comments
 (0)