mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-09-01 06:30:52 +02:00
back to version 1.0
respect most review comments
This commit is contained in:
parent
4f309d5b79
commit
f158b9ca9c
3 changed files with 28 additions and 24 deletions
|
@ -1,10 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
project(
|
||||
GreeterTests
|
||||
VERSION 1.1
|
||||
LANGUAGES CXX
|
||||
)
|
||||
project(GreeterTests LANGUAGES CXX)
|
||||
|
||||
# ---- Options ----
|
||||
|
||||
|
@ -43,16 +39,16 @@ CPMAddPackage(
|
|||
|
||||
file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)
|
||||
add_executable(GreeterTests ${sources})
|
||||
target_link_libraries(GreeterTests doctest Greeter::Greeter)
|
||||
target_link_libraries(GreeterTests doctest::doctest Greeter::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")
|
||||
target_compile_options(Greeter PRIVATE -Wall -pedantic -Wextra -Werror)
|
||||
target_compile_options(Greeter PUBLIC -Wall -Wpedantic -Wextra -Werror)
|
||||
elseif(MSVC)
|
||||
target_compile_options(Greeter PRIVATE /W4 /WX)
|
||||
target_compile_options(Greeter PUBLIC /W4 /WX)
|
||||
target_compile_definitions(GreeterTests PUBLIC DOCTEST_CONFIG_USE_STD_HEADERS)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -63,13 +59,16 @@ 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)
|
||||
# include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake) doctest_discover_tests(GreeterTests)
|
||||
# Warning: if doctest is imported with find_package() this will fail! CK
|
||||
if(DEFINED doctest_SOURCE_DIR)
|
||||
include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
|
||||
doctest_discover_tests(GreeterTests)
|
||||
else()
|
||||
add_test(greeterTests GreeterTests)
|
||||
endif()
|
||||
|
||||
# ---- code coverage ----
|
||||
|
||||
if(ENABLE_TEST_COVERAGE AND NOT TEST_INSTALLED_VERSION)
|
||||
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