blob: 68e089d09f0e7730bd4c84b62972adfc36b8fb44 [file] [log] [blame]
onqtam98e12af2017-04-16 22:11:21 +03001get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
2project(${PROJECT_NAME})
3
4set(files
5 main.cpp
onqtam12d55982017-04-16 22:35:27 +03006 doctest_proxy.h
onqtam98e12af2017-04-16 22:11:21 +03007 coverage_maxout.cpp
8 alternative_macros.cpp
9 assertion_macros.cpp
10 stringification.cpp
11 subcases.cpp
onqtam119cfb62017-04-17 10:46:55 +030012 logging.cpp
13 templated_test_cases.cpp
14 test_suites.cpp
onqtam98e12af2017-04-16 22:11:21 +030015)
16
onqtam12d55982017-04-16 22:35:27 +030017# add the normal build
18doctest_add_executable(${PROJECT_NAME} ${files})
19target_compile_definitions(${PROJECT_NAME} PRIVATE DOCTEST_CONFIG_COLORS_NONE) # easy way to fix test coverage
20target_link_libraries(${PROJECT_NAME} doctest)
onqtam98e12af2017-04-16 22:11:21 +030021
22# add per-file tests
23foreach(f ${files})
onqtam119cfb62017-04-17 10:46:55 +030024 doctest_add_test(NAME ${f} COMMAND $<TARGET_FILE:${PROJECT_NAME}> --dt-no-skipped-summary=1 --source-file=*${f})
onqtam98e12af2017-04-16 22:11:21 +030025endforeach()
26
27## queries
28#doctest_add_test(NAME help COMMAND $<TARGET_FILE:${PROJECT_NAME}> -dt-h)
29#doctest_add_test(NAME version COMMAND $<TARGET_FILE:${PROJECT_NAME}> -v)
30#doctest_add_test(NAME count COMMAND $<TARGET_FILE:${PROJECT_NAME}> -c)
31#doctest_add_test(NAME list_test_cases COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ltc)
32#doctest_add_test(NAME list_test_suites COMMAND $<TARGET_FILE:${PROJECT_NAME}> -lts)
33#
34## options
35#doctest_add_test(NAME successful COMMAND $<TARGET_FILE:${PROJECT_NAME}> -s=true -e=Off -sfe=*main*) # exclude main because of RawMemoryToStr
36#doctest_add_test(NAME abort_after COMMAND $<TARGET_FILE:${PROJECT_NAME}> -aa=3 -no-colors)
37#doctest_add_test(NAME first_last COMMAND $<TARGET_FILE:${PROJECT_NAME}> -f=2 -l=5)
38#doctest_add_test(NAME filter_1 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tc=assert*********)
39#doctest_add_test(NAME filter_2 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tce=???ert*)
40#doctest_add_test(NAME filter_3 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -sf=asgghdgsa)
41#doctest_add_test(NAME filter_4 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -sfe=*test.cpp*)
42#doctest_add_test(NAME filter_5 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ts=ts1)
43#doctest_add_test(NAME filter_6 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tse=ts1)
44#doctest_add_test(NAME order_1 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ob=suite)
45#doctest_add_test(NAME order_2 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -ob=name)
46#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 +030047
48# add variation of the build with disabled tests - should still compile
49doctest_add_executable(disabled ${files})
50target_link_libraries(disabled doctest)
51if(MSVC)
52 target_compile_options(disabled PRIVATE /wd4505) # unreferenced local function has been removed
53endif()
54if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
55 target_compile_options(disabled PRIVATE -Wno-unneeded-internal-declaration)
56 target_compile_options(disabled PRIVATE -Wno-unused-variable) # TODO: think about fixing this in a different way!
57endif()
58target_compile_definitions(disabled PRIVATE DOCTEST_CONFIG_DISABLE)
59doctest_add_test(NAME disabled COMMAND $<TARGET_FILE:disabled>)