mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-08-30 21:51:12 +02:00
enable compiler warnings for the library target when building tests
This commit is contained in:
parent
ed8e6d3b19
commit
f5a524fe43
1 changed files with 8 additions and 5 deletions
|
@ -42,10 +42,13 @@ target_link_libraries(GreeterTests doctest Greeter)
|
|||
|
||||
set_target_properties(GreeterTests PROPERTIES CXX_STANDARD 17)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
target_compile_options(GreeterTests PRIVATE -Wall -pedantic -Wextra -Werror)
|
||||
elseif(MSVC)
|
||||
target_compile_options(GreeterTests PRIVATE /W4)
|
||||
# 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)
|
||||
elseif(MSVC)
|
||||
target_compile_options(Greeter PUBLIC /W4)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ---- Add GreeterTests ----
|
||||
|
@ -62,6 +65,6 @@ doctest_discover_tests(GreeterTests)
|
|||
# ---- code coverage ----
|
||||
|
||||
if (ENABLE_TEST_COVERAGE)
|
||||
set_target_properties(Greeter PROPERTIES CXX_STANDARD 17 COMPILE_FLAGS "-O0 -g -fprofile-arcs -ftest-coverage --coverage")
|
||||
target_compile_options(Greeter PRIVATE -O0 -g -fprofile-arcs -ftest-coverage --coverage)
|
||||
target_link_options(Greeter PUBLIC "--coverage")
|
||||
endif()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue