Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ jobs:
run: |
cmake ${{ matrix.package }} \
-B ${{ matrix.package }}/build \
-D BUILD_TESTING=ON

- name: Check code formatting
run: |
cmake --build ${{ matrix.package }}/build --target fix-format
git diff --exit-code HEAD
-D BUILD_TESTING=ON \
-D CHECK_FORMAT=ON \
-D CHECK_WARNING=ON \
-D CHECK_COVERAGE=ON

- name: Build project
run: cmake --build ${{ matrix.package }}/build
Expand All @@ -43,6 +41,9 @@ jobs:
${{ matrix.package }}/test/*
fail-under-line: 100

- name: Check diff
run: git diff --exit-code HEAD

debug-msvc:
runs-on: windows-latest
strategy:
Expand All @@ -57,7 +58,8 @@ jobs:
cmake ${{ matrix.package }} `
-B ${{ matrix.package }}/build `
-D CMAKE_CXX_COMPILER=cl `
-D BUILD_TESTING=ON
-D BUILD_TESTING=ON `
-D CHECK_WARNING=ON

- name: Build project
run: cmake --build ${{ matrix.package }}/build
Expand Down
3 changes: 2 additions & 1 deletion error/.cmake-format
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"line_width": 120
"line_width": 120,
"max_subgroups_hwrap": 3
}
26 changes: 16 additions & 10 deletions error/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ target_link_libraries(error PUBLIC fmt)

# Check if this project is the main project
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
option(CHECK_FORMAT "Enable source code formatting check" OFF)
option(CHECK_WARNING "Enable static analysis warning check" OFF)
option(CHECK_COVERAGE "Enable test coverage check" OFF)

# Import Format.cmake to format source code
cpmaddpackage("gh:TheLartians/[email protected]")
if(CHECK_FORMAT)
cpmaddpackage("gh:TheLartians/[email protected]")
add_dependencies(error fix-format)
endif()

if(BUILD_TESTING)
enable_testing()
Expand All @@ -30,21 +37,20 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
endif()

# Get all targets in this directory
get_property(
TARGETS
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY BUILDSYSTEM_TARGETS)
get_property(TARGETS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)

foreach(TARGET IN LISTS TARGETS)
# Statically analyze code by checking for warnings
if(MSVC)
target_compile_options(${TARGET} PRIVATE /WX /permissive- /W4 /w14640 /EHsc)
else()
target_compile_options(${TARGET} PRIVATE -Werror -Wall -Wextra -Wnon-virtual-dtor -Wpedantic)
if(CHECK_WARNING)
if(MSVC)
target_compile_options(${TARGET} PRIVATE /WX /permissive- /W4 /w14640 /EHsc)
else()
target_compile_options(${TARGET} PRIVATE -Werror -Wall -Wextra -Wnon-virtual-dtor -Wpedantic)
endif()
endif()

# Enable support to check for test coverage
if(BUILD_TESTING AND NOT MSVC)
if(BUILD_TESTING AND CHECK_COVERAGE AND NOT MSVC)
target_compile_options(${TARGET} PRIVATE --coverage -O0)
target_link_options(${TARGET} PRIVATE --coverage)
endif()
Expand Down