blob: 2905f2744df66918af47253bce4d2af61fc18478 [file] [log] [blame]
onqtam98e12af2017-04-16 22:11:21 +03001get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
2project(${PROJECT_NAME})
3
onqtam7cc0e962017-04-17 23:30:36 +03004################################################################################
5## BUILD ALL EXAMPLE SOURCES INTO A SINGLE BINARY AND EXECUTE TESTS ON EACH FILE
6################################################################################
7
onqtam98e12af2017-04-16 22:11:21 +03008set(files
9 main.cpp
onqtam12d55982017-04-16 22:35:27 +030010 doctest_proxy.h
onqtam7cc0e962017-04-17 23:30:36 +030011 header.h
onqtam98e12af2017-04-16 22:11:21 +030012 coverage_maxout.cpp
13 alternative_macros.cpp
14 assertion_macros.cpp
15 stringification.cpp
16 subcases.cpp
onqtam119cfb62017-04-17 10:46:55 +030017 logging.cpp
18 templated_test_cases.cpp
onqtam378d6702017-04-19 11:30:03 +030019 test_cases_and_suites.cpp
onqtam98e12af2017-04-16 22:11:21 +030020)
21
onqtam12d55982017-04-16 22:35:27 +030022doctest_add_executable(${PROJECT_NAME} ${files})
onqtam321f2702017-05-01 19:14:58 +030023target_compile_definitions(${PROJECT_NAME} PRIVATE DOCTEST_CONFIG_COLORS_NONE DOCTEST_CONFIG_NO_POSIX_SIGNALS) # easy way to fix test coverage
onqtam98e12af2017-04-16 22:11:21 +030024
25# add per-file tests
26foreach(f ${files})
onqtam119cfb62017-04-17 10:46:55 +030027 doctest_add_test(NAME ${f} COMMAND $<TARGET_FILE:${PROJECT_NAME}> --dt-no-skipped-summary=1 --source-file=*${f})
onqtam98e12af2017-04-16 22:11:21 +030028endforeach()
29
onqtam321f2702017-05-01 19:14:58 +030030# queries
31doctest_add_test(NAME help COMMAND $<TARGET_FILE:${PROJECT_NAME}> -dt-h)
32doctest_add_test(NAME version COMMAND $<TARGET_FILE:${PROJECT_NAME}> -v)
33doctest_add_test(NAME count COMMAND $<TARGET_FILE:${PROJECT_NAME}> -c)
34doctest_add_test(NAME list_test_cases COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ltc)
35doctest_add_test(NAME list_test_suites COMMAND $<TARGET_FILE:${PROJECT_NAME}> -lts)
36
37doctest_add_test(NAME all_binary_success COMMAND $<TARGET_FILE:${PROJECT_NAME}> --test-case="all binary assertions" --success)
38
onqtam98e12af2017-04-16 22:11:21 +030039## options
40#doctest_add_test(NAME successful COMMAND $<TARGET_FILE:${PROJECT_NAME}> -s=true -e=Off -sfe=*main*) # exclude main because of RawMemoryToStr
41#doctest_add_test(NAME abort_after COMMAND $<TARGET_FILE:${PROJECT_NAME}> -aa=3 -no-colors)
42#doctest_add_test(NAME first_last COMMAND $<TARGET_FILE:${PROJECT_NAME}> -f=2 -l=5)
43#doctest_add_test(NAME filter_1 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tc=assert*********)
44#doctest_add_test(NAME filter_2 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tce=???ert*)
45#doctest_add_test(NAME filter_3 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -sf=asgghdgsa)
46#doctest_add_test(NAME filter_4 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -sfe=*test.cpp*)
47#doctest_add_test(NAME filter_5 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ts=ts1)
48#doctest_add_test(NAME filter_6 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tse=ts1)
49#doctest_add_test(NAME order_1 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ob=suite)
50#doctest_add_test(NAME order_2 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ob=name)
51#doctest_add_test(NAME order_3 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ob=rand -rs=324 -sfe=*) # sfe=* to exclude all tests for no output
onqtame0f18802017-04-16 23:38:33 +030052
onqtam7cc0e962017-04-17 23:30:36 +030053################################################################################
54## VARIATION OF THE BUILD WITH DOCTEST DISABLED - SHOULD STILL COMPILE
55################################################################################
56
onqtamf6d1a512017-05-01 13:56:12 +030057return() # temp hack
58
onqtame0f18802017-04-16 23:38:33 +030059doctest_add_executable(disabled ${files})
onqtame0f18802017-04-16 23:38:33 +030060target_compile_definitions(disabled PRIVATE DOCTEST_CONFIG_DISABLE)
onqtam7cc0e962017-04-17 23:30:36 +030061
onqtame0f18802017-04-16 23:38:33 +030062doctest_add_test(NAME disabled COMMAND $<TARGET_FILE:disabled>)
onqtam7cc0e962017-04-17 23:30:36 +030063
onqtamd320ac22017-04-17 11:44:32 +030064# TODO: think about fixing these in a different way! - see issue #61 or commit 6b61e8aa3818c5ea100cedc1bb48a60ea10df6e8
65if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
66 target_compile_options(disabled PRIVATE /wd4505) # unreferenced local function has been removed
onqtamcb7bad62017-04-19 11:19:57 +030067 target_compile_options(disabled PRIVATE /wd4100) # unreferenced formal parameter
onqtamaf07cbb2017-04-19 19:40:43 +030068 target_compile_options(disabled PRIVATE /wd4189) # local variable is initialized but not referenced
onqtamd320ac22017-04-17 11:44:32 +030069elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
onqtam135a50e2017-04-18 11:48:20 +030070 target_compile_options(disabled PRIVATE -Wno-unknown-warning-option)
onqtamd320ac22017-04-17 11:44:32 +030071 target_compile_options(disabled PRIVATE -Wno-unneeded-internal-declaration)
onqtamcb7bad62017-04-19 11:19:57 +030072 target_compile_options(disabled PRIVATE -Wno-unused-parameter)
onqtamc79b7542017-04-19 20:47:13 +030073 target_compile_options(disabled PRIVATE -Wno-unused-variable)
74elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
onqtamcb7bad62017-04-19 11:19:57 +030075 target_compile_options(disabled PRIVATE -Wno-unused-function)
onqtamc79b7542017-04-19 20:47:13 +030076 target_compile_options(disabled PRIVATE -Wno-unused-parameter)
onqtamaf07cbb2017-04-19 19:40:43 +030077 target_compile_options(disabled PRIVATE -Wno-unused-variable)
onqtamd320ac22017-04-17 11:44:32 +030078endif()