mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-08-30 13:41:13 +02:00
Enable cmake formatting (#53)
* enable cmake formatting * update style check workflow * update readme * update wording
This commit is contained in:
parent
4e87a9410a
commit
866ae707e5
8 changed files with 142 additions and 85 deletions
|
@ -1,8 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
project(GreeterTests
|
||||
LANGUAGES CXX
|
||||
)
|
||||
project(GreeterTests LANGUAGES CXX)
|
||||
|
||||
# ---- Options ----
|
||||
|
||||
|
@ -23,19 +21,20 @@ CPMAddPackage(
|
|||
GIT_TAG 2.3.7
|
||||
)
|
||||
|
||||
if (TEST_INSTALLED_VERSION)
|
||||
if(TEST_INSTALLED_VERSION)
|
||||
find_package(Greeter REQUIRED)
|
||||
else()
|
||||
CPMAddPackage(
|
||||
NAME Greeter
|
||||
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..
|
||||
)
|
||||
CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||
endif()
|
||||
|
||||
CPMAddPackage(
|
||||
NAME Format.cmake
|
||||
GITHUB_REPOSITORY TheLartians/Format.cmake
|
||||
VERSION 1.5.2
|
||||
VERSION 1.6
|
||||
OPTIONS # enable cmake formatting
|
||||
"FORMAT_CHECK_CMAKE ON"
|
||||
# skip CPM.cmake
|
||||
"CMAKE_FORMAT_EXCLUDE cmake/CPM.cmake"
|
||||
)
|
||||
|
||||
# ---- Create binary ----
|
||||
|
@ -47,8 +46,8 @@ target_link_libraries(GreeterTests doctest Greeter)
|
|||
set_target_properties(GreeterTests PROPERTIES CXX_STANDARD 17)
|
||||
|
||||
# enable compiler warnings
|
||||
if (NOT TEST_INSTALLED_VERSION)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
if(NOT TEST_INSTALLED_VERSION)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
target_compile_options(Greeter PUBLIC -Wall -pedantic -Wextra -Werror)
|
||||
elseif(MSVC)
|
||||
target_compile_options(Greeter PUBLIC /W4 /WX)
|
||||
|
@ -58,18 +57,17 @@ endif()
|
|||
|
||||
# ---- Add GreeterTests ----
|
||||
|
||||
ENABLE_TESTING()
|
||||
enable_testing()
|
||||
|
||||
# Note: doctest and similar testing frameworks can automatically configure CMake tests
|
||||
# For other testing frameworks add the tests target instead:
|
||||
# ADD_TEST(GreeterTests GreeterTests)
|
||||
# Note: doctest and similar testing frameworks can automatically configure CMake tests For other
|
||||
# testing frameworks add the tests target instead: ADD_TEST(GreeterTests GreeterTests)
|
||||
|
||||
include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
|
||||
doctest_discover_tests(GreeterTests)
|
||||
|
||||
# ---- code coverage ----
|
||||
|
||||
if (ENABLE_TEST_COVERAGE)
|
||||
if(ENABLE_TEST_COVERAGE)
|
||||
target_compile_options(Greeter PUBLIC -O0 -g -fprofile-arcs -ftest-coverage)
|
||||
target_link_options(Greeter PUBLIC -fprofile-arcs -ftest-coverage)
|
||||
endif()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue