Skip to content

Commit 000cc4b

Browse files
authored
build: enable format, warning, and coverage by default (#56)
* build: remove `CHECK_FORMAT` option * build: remove `CHECK_WARNING` option * build: remove `CHECK_COVERAGE` option * build: modify `fix-format` target to be called manually
1 parent 5a5fbcb commit 000cc4b

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ jobs:
1616
run: |
1717
cmake . \
1818
-B build \
19-
-D BUILD_TESTING=ON \
20-
-D CHECK_FORMAT=ON \
21-
-D CHECK_WARNING=ON \
22-
-D CHECK_COVERAGE=ON
19+
-D BUILD_TESTING=ON
20+
21+
- name: Check formatting
22+
run: |
23+
cmake --build build --target fix-format
24+
git diff --exit-code HEAD
2325
2426
- name: Build project
2527
run: cmake --build build
@@ -49,8 +51,7 @@ jobs:
4951
cmake . `
5052
-B build `
5153
-D CMAKE_CXX_COMPILER=cl `
52-
-D BUILD_TESTING=ON `
53-
-D CHECK_WARNING=ON
54+
-D BUILD_TESTING=ON
5455
5556
- name: Build project
5657
run: cmake --build build

CMakeLists.txt

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,10 @@ target_compile_features(errors PRIVATE cxx_std_20)
1414

1515
# Check if this project is the main project
1616
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
17-
option(CHECK_FORMAT "Enable source code formatting check" OFF)
18-
option(CHECK_WARNING "Enable static analysis warning check" OFF)
19-
option(CHECK_COVERAGE "Enable test coverage check" OFF)
2017
option(BUILD_DOCS "Enable documentations build" OFF)
2118

2219
# Import Format.cmake to format source code
23-
if(CHECK_FORMAT)
24-
cpmaddpackage("gh:threeal/Format.cmake#auto-install-cmake-format")
25-
add_dependencies(errors fix-format)
26-
endif()
20+
cpmaddpackage("gh:threeal/Format.cmake#auto-install-cmake-format")
2721

2822
if(BUILD_TESTING)
2923
enable_testing()
@@ -43,16 +37,14 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
4337

4438
foreach(TARGET IN LISTS TARGETS)
4539
# Statically analyze code by checking for warnings
46-
if(CHECK_WARNING)
47-
if(MSVC)
48-
target_compile_options(${TARGET} PRIVATE /WX /permissive- /W4 /w14640 /EHsc)
49-
else()
50-
target_compile_options(${TARGET} PRIVATE -Werror -Wall -Wextra -Wnon-virtual-dtor -Wpedantic)
51-
endif()
40+
if(MSVC)
41+
target_compile_options(${TARGET} PRIVATE /WX /permissive- /W4 /w14640 /EHsc)
42+
else()
43+
target_compile_options(${TARGET} PRIVATE -Werror -Wall -Wextra -Wnon-virtual-dtor -Wpedantic)
5244
endif()
5345

5446
# Enable support to check for test coverage
55-
if(BUILD_TESTING AND CHECK_COVERAGE AND NOT MSVC)
47+
if(BUILD_TESTING AND NOT MSVC)
5648
target_compile_options(${TARGET} PRIVATE --coverage -O0)
5749
target_link_options(${TARGET} PRIVATE --coverage)
5850
endif()

0 commit comments

Comments
 (0)