blob: 9d3e503ce9c9222d7a4e9cf262074d55c408af69 [file] [log] [blame]
onqtam8cd8b3b2017-05-15 00:50:03 +03001cmake_minimum_required(VERSION 3.0)
2
3project(all_features)
4
5include(../../scripts/cmake/common.cmake)
6
ncihnegnc5458f22019-01-28 05:08:18 -08007include_directories(../../)
onqtam8cd8b3b2017-05-15 00:50:03 +03008
onqtam7cc0e962017-04-17 23:30:36 +03009################################################################################
10## BUILD ALL EXAMPLE SOURCES INTO A SINGLE BINARY AND EXECUTE TESTS ON EACH FILE
11################################################################################
12
onqtamc9b4e1f2018-08-17 14:20:59 +030013set(files_with_output
onqtam98e12af2017-04-16 22:11:21 +030014 main.cpp
onqtam12d55982017-04-16 22:35:27 +030015 doctest_proxy.h
onqtam7cc0e962017-04-17 23:30:36 +030016 header.h
onqtam98e12af2017-04-16 22:11:21 +030017 alternative_macros.cpp
18 assertion_macros.cpp
19 stringification.cpp
20 subcases.cpp
onqtam119cfb62017-04-17 10:46:55 +030021 logging.cpp
22 templated_test_cases.cpp
onqtam378d6702017-04-19 11:30:03 +030023 test_cases_and_suites.cpp
onqtam8171c482018-07-03 20:31:18 +030024 asserts_used_outside_of_tests.cpp
onqtam98e12af2017-04-16 22:11:21 +030025)
26
onqtamc9b4e1f2018-08-17 14:20:59 +030027set(files_all
28 ${files_with_output}
29 concurrency.cpp
30 ../../scripts/coverage_maxout.cpp
31)
32
onqtam3ac4c3f2018-06-01 15:31:06 +030033# add the executable
Dimitrij Mijoski0dbbd4f2019-03-02 17:37:34 +010034add_executable(${PROJECT_NAME} ${files_all})
35target_link_libraries(${PROJECT_NAME} doctest ${CMAKE_THREAD_LIBS_INIT})
onqtam3ac4c3f2018-06-01 15:31:06 +030036
onqtamf0f899b2017-05-02 21:40:41 +030037# easy way to fix test coverage - disable colors and crash handling
38target_compile_definitions(${PROJECT_NAME} PRIVATE
39 DOCTEST_CONFIG_COLORS_NONE
40 DOCTEST_CONFIG_NO_POSIX_SIGNALS
41 DOCTEST_CONFIG_NO_WINDOWS_SEH)
onqtam98e12af2017-04-16 22:11:21 +030042
onqtam3ac4c3f2018-06-01 15:31:06 +030043# omit the version and the num test cases skipped from the summary - this way the output will change less often
44set(common_args COMMAND $<TARGET_FILE:${PROJECT_NAME}> --no-skipped-summary --no-version --reporters=console)
onqtam76305352017-05-01 20:25:09 +030045
onqtam98e12af2017-04-16 22:11:21 +030046# add per-file tests
onqtamc9b4e1f2018-08-17 14:20:59 +030047foreach(f ${files_with_output})
onqtam5dbcb1e2017-05-02 23:07:56 +030048 doctest_add_test(NAME ${f} ${common_args} -sf=*${f})
onqtam98e12af2017-04-16 22:11:21 +030049endforeach()
50
onqtamc9b4e1f2018-08-17 14:20:59 +030051# add this separately since it shouldn't have output compared to reference output - due to concurrency
onqtam7b7bb8a2018-08-17 16:20:16 +030052# not adding it for MinGW since it crashes when using mingw-w64-x86_64-8.1.0-release-posix-seh-rt_v6-rev0
onqtamb031dd02019-01-15 20:25:19 +020053# (also disabled for old XCode builds on travis where there is no thread_local support and this is defined in the build matrix)
onqtameb89a022019-01-14 00:16:11 +020054if(NOT MINGW AND NOT DEFINED DOCTEST_THREAD_LOCAL)
onqtam7b7bb8a2018-08-17 16:20:16 +030055 doctest_add_test(NO_OUTPUT NAME concurrency.cpp ${common_args} -sf=*concurrency.cpp)
56endif()
onqtamc9b4e1f2018-08-17 14:20:59 +030057
onqtam3ac4c3f2018-06-01 15:31:06 +030058# add this separately since the file has a non-straightforward path
59doctest_add_test(NAME coverage_maxout.cpp ${common_args} -sf=*coverage_maxout.cpp)
60
onqtam76305352017-05-01 20:25:09 +030061# queries
onqtamf6370e22017-05-03 06:38:27 +030062doctest_add_test(NAME version COMMAND $<TARGET_FILE:${PROJECT_NAME}> -v)
onqtam5dbcb1e2017-05-02 23:07:56 +030063doctest_add_test(NAME help ${common_args} -h)
64doctest_add_test(NAME count ${common_args} -c -sf=*coverage*)
65doctest_add_test(NAME list_test_cases ${common_args} -ltc -sf=*coverage*)
66doctest_add_test(NAME list_test_suites ${common_args} -lts -sf=*coverage*)
onqtam3ac4c3f2018-06-01 15:31:06 +030067doctest_add_test(NAME list_reporters ${common_args} -lr -sf=*coverage*)
onqtam321f2702017-05-01 19:14:58 +030068
onqtam89da6542017-05-02 21:10:42 +030069# options
onqtam5dbcb1e2017-05-02 23:07:56 +030070doctest_add_test(NAME all_binary ${common_args} -tc=all?binary* -s) # print all binary asserts - for getAssertString()
71doctest_add_test(NAME abort_after ${common_args} -aa=2 -e=off -sf=*coverage*) # abort after 2 assert fails and parse a negative
72doctest_add_test(NAME first_last ${common_args} -f=2 -l=4 -sf=*coverage*) # run a range
onqtam14ddb1e2017-05-02 23:19:09 +030073doctest_add_test(NAME filter_1 ${common_args} -ts=none) # should filter out all
onqtamf6370e22017-05-03 06:38:27 +030074doctest_add_test(NAME filter_2 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tse=* -nv) # should filter out all + print skipped
onqtam14ddb1e2017-05-02 23:19:09 +030075doctest_add_test(NAME filter_3 ${common_args} -sc=from*,sc* -sce=sc2 -sf=*subcases*) # enter a specific subcase - sc1
onqtame6412e12017-05-07 16:21:36 +030076doctest_add_test(NAME order_1 ${common_args} -ob=suite -ns -sf=*test_cases_and_suites*)
onqtam14ddb1e2017-05-02 23:19:09 +030077doctest_add_test(NAME order_2 ${common_args} -ob=name -sf=*test_cases_and_suites*)
78doctest_add_test(NAME order_3 ${common_args} -ob=rand -sfe=*) # exclude everything for no output
onqtame0f18802017-04-16 23:38:33 +030079
onqtam7cc0e962017-04-17 23:30:36 +030080################################################################################
81## VARIATION OF THE BUILD WITH DOCTEST DISABLED - SHOULD STILL COMPILE
82################################################################################
83
onqtamaec53d22017-05-03 06:29:47 +030084if(DEFINED ENV{CODE_COVERAGE})
85 return() # do not continue with the disabled example
86endif()
onqtamf6d1a512017-05-01 13:56:12 +030087
Dimitrij Mijoski0dbbd4f2019-03-02 17:37:34 +010088add_executable(disabled ${files_all})
onqtame0f18802017-04-16 23:38:33 +030089target_compile_definitions(disabled PRIVATE DOCTEST_CONFIG_DISABLE)
Dimitrij Mijoski0dbbd4f2019-03-02 17:37:34 +010090target_link_libraries(disabled doctest ${CMAKE_THREAD_LIBS_INIT})
onqtam7cc0e962017-04-17 23:30:36 +030091
onqtame0f18802017-04-16 23:38:33 +030092doctest_add_test(NAME disabled COMMAND $<TARGET_FILE:disabled>)
onqtam7cc0e962017-04-17 23:30:36 +030093
onqtamd320ac22017-04-17 11:44:32 +030094# TODO: think about fixing these in a different way! - see issue #61 or commit 6b61e8aa3818c5ea100cedc1bb48a60ea10df6e8
Martin Moened8a7edc2017-08-01 17:08:08 +020095if(MSVC)
onqtamd320ac22017-04-17 11:44:32 +030096 target_compile_options(disabled PRIVATE /wd4505) # unreferenced local function has been removed
onqtamcb7bad62017-04-19 11:19:57 +030097 target_compile_options(disabled PRIVATE /wd4100) # unreferenced formal parameter
onqtamaf07cbb2017-04-19 19:40:43 +030098 target_compile_options(disabled PRIVATE /wd4189) # local variable is initialized but not referenced
onqtamd320ac22017-04-17 11:44:32 +030099elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
onqtam135a50e2017-04-18 11:48:20 +0300100 target_compile_options(disabled PRIVATE -Wno-unknown-warning-option)
onqtamd320ac22017-04-17 11:44:32 +0300101 target_compile_options(disabled PRIVATE -Wno-unneeded-internal-declaration)
onqtama82c1e42017-05-07 17:36:41 +0300102 target_compile_options(disabled PRIVATE -Wno-unused-function)
onqtamcb7bad62017-04-19 11:19:57 +0300103 target_compile_options(disabled PRIVATE -Wno-unused-parameter)
onqtamc79b7542017-04-19 20:47:13 +0300104 target_compile_options(disabled PRIVATE -Wno-unused-variable)
onqtameb96d162017-09-11 14:26:32 +0300105 target_compile_options(disabled PRIVATE -Wno-unused-template)
onqtamc79b7542017-04-19 20:47:13 +0300106elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
onqtamcb7bad62017-04-19 11:19:57 +0300107 target_compile_options(disabled PRIVATE -Wno-unused-function)
onqtamc79b7542017-04-19 20:47:13 +0300108 target_compile_options(disabled PRIVATE -Wno-unused-parameter)
onqtamaf07cbb2017-04-19 19:40:43 +0300109 target_compile_options(disabled PRIVATE -Wno-unused-variable)
onqtamd320ac22017-04-17 11:44:32 +0300110endif()