onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 1 | get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) |
| 2 | project(${PROJECT_NAME}) |
| 3 | |
| 4 | set(files |
| 5 | main.cpp |
onqtam | 12d5598 | 2017-04-16 22:35:27 +0300 | [diff] [blame] | 6 | doctest_proxy.h |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 7 | coverage_maxout.cpp |
| 8 | alternative_macros.cpp |
| 9 | assertion_macros.cpp |
| 10 | stringification.cpp |
| 11 | subcases.cpp |
onqtam | 119cfb6 | 2017-04-17 10:46:55 +0300 | [diff] [blame^] | 12 | logging.cpp |
| 13 | templated_test_cases.cpp |
| 14 | test_suites.cpp |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 15 | ) |
| 16 | |
onqtam | 12d5598 | 2017-04-16 22:35:27 +0300 | [diff] [blame] | 17 | # add the normal build |
| 18 | doctest_add_executable(${PROJECT_NAME} ${files}) |
| 19 | target_compile_definitions(${PROJECT_NAME} PRIVATE DOCTEST_CONFIG_COLORS_NONE) # easy way to fix test coverage |
| 20 | target_link_libraries(${PROJECT_NAME} doctest) |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 21 | |
| 22 | # add per-file tests |
| 23 | foreach(f ${files}) |
onqtam | 119cfb6 | 2017-04-17 10:46:55 +0300 | [diff] [blame^] | 24 | doctest_add_test(NAME ${f} COMMAND $<TARGET_FILE:${PROJECT_NAME}> --dt-no-skipped-summary=1 --source-file=*${f}) |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 25 | endforeach() |
| 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 |
onqtam | e0f1880 | 2017-04-16 23:38:33 +0300 | [diff] [blame] | 47 | |
| 48 | # add variation of the build with disabled tests - should still compile |
| 49 | doctest_add_executable(disabled ${files}) |
| 50 | target_link_libraries(disabled doctest) |
| 51 | if(MSVC) |
| 52 | target_compile_options(disabled PRIVATE /wd4505) # unreferenced local function has been removed |
| 53 | endif() |
| 54 | if(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! |
| 57 | endif() |
| 58 | target_compile_definitions(disabled PRIVATE DOCTEST_CONFIG_DISABLE) |
| 59 | doctest_add_test(NAME disabled COMMAND $<TARGET_FILE:disabled>) |