Feature/extend build dependency (#80)

* add build time dependency to static lib

the header only fmt lib is used to show this

* use add_test() and add a warning why

doctest_discover_tests() is only availabe if doctest is not imported with
find_packag()

* cmake-format file

* fix missed comment

* back to version 1.0

respect most review comments

* fix typo

* update used CMP package versions

* respect most review comments

no default cxx language settings
install fmt
link against fmt::fmt
export dependency too if not needed
...

* use generic expression as recommended

* Update CMakeLists.txt

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>

* changes acording review comments

update to current PackageProject version 1.5.0 too

* Update CMakeLists.txt

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>

* respect review comment

remove NOLINT comment

* back to begining

needs to use doctest cmake modules ...
it is not my idea!

Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
This commit is contained in:
Claus Klein 2021-02-19 09:46:11 +01:00 committed by GitHub
parent b58e0717f4
commit 2db60f2ccb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 30 deletions

View file

@ -18,7 +18,7 @@ include(../cmake/CPM.cmake)
CPMAddPackage(
NAME doctest
GITHUB_REPOSITORY onqtam/doctest
GIT_TAG 2.3.7
GIT_TAG 2.4.5
)
if(TEST_INSTALLED_VERSION)
@ -39,14 +39,13 @@ 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 PUBLIC -Wall -pedantic -Wextra -Werror)
target_compile_options(Greeter PUBLIC -Wall -Wpedantic -Wextra -Werror)
elseif(MSVC)
target_compile_options(Greeter PUBLIC /W4 /WX)
target_compile_definitions(GreeterTests PUBLIC DOCTEST_CONFIG_USE_STD_HEADERS)
@ -57,8 +56,8 @@ endif()
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(NAME greeterTests COMMAND GreeterTests)
include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
doctest_discover_tests(GreeterTests)