onqtam | 8cd8b3b | 2017-05-15 00:50:03 +0300 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.0) |
| 2 | |
| 3 | project(all_features) |
| 4 | |
| 5 | include(../../scripts/cmake/common.cmake) |
| 6 | |
ncihnegn | c5458f2 | 2019-01-28 05:08:18 -0800 | [diff] [blame^] | 7 | include_directories(../../) |
onqtam | 8cd8b3b | 2017-05-15 00:50:03 +0300 | [diff] [blame] | 8 | |
onqtam | 7cc0e96 | 2017-04-17 23:30:36 +0300 | [diff] [blame] | 9 | ################################################################################ |
| 10 | ## BUILD ALL EXAMPLE SOURCES INTO A SINGLE BINARY AND EXECUTE TESTS ON EACH FILE |
| 11 | ################################################################################ |
| 12 | |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 13 | set(files_with_output |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 14 | main.cpp |
onqtam | 12d5598 | 2017-04-16 22:35:27 +0300 | [diff] [blame] | 15 | doctest_proxy.h |
onqtam | 7cc0e96 | 2017-04-17 23:30:36 +0300 | [diff] [blame] | 16 | header.h |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 17 | alternative_macros.cpp |
| 18 | assertion_macros.cpp |
| 19 | stringification.cpp |
| 20 | subcases.cpp |
onqtam | 119cfb6 | 2017-04-17 10:46:55 +0300 | [diff] [blame] | 21 | logging.cpp |
| 22 | templated_test_cases.cpp |
onqtam | 378d670 | 2017-04-19 11:30:03 +0300 | [diff] [blame] | 23 | test_cases_and_suites.cpp |
onqtam | 8171c48 | 2018-07-03 20:31:18 +0300 | [diff] [blame] | 24 | asserts_used_outside_of_tests.cpp |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 25 | ) |
| 26 | |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 27 | set(files_all |
| 28 | ${files_with_output} |
| 29 | concurrency.cpp |
| 30 | ../../scripts/coverage_maxout.cpp |
| 31 | ) |
| 32 | |
onqtam | 3ac4c3f | 2018-06-01 15:31:06 +0300 | [diff] [blame] | 33 | # add the executable |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 34 | doctest_add_executable(${PROJECT_NAME} ${files_all}) |
onqtam | 3ac4c3f | 2018-06-01 15:31:06 +0300 | [diff] [blame] | 35 | |
onqtam | f0f899b | 2017-05-02 21:40:41 +0300 | [diff] [blame] | 36 | # easy way to fix test coverage - disable colors and crash handling |
| 37 | target_compile_definitions(${PROJECT_NAME} PRIVATE |
| 38 | DOCTEST_CONFIG_COLORS_NONE |
| 39 | DOCTEST_CONFIG_NO_POSIX_SIGNALS |
| 40 | DOCTEST_CONFIG_NO_WINDOWS_SEH) |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 41 | |
onqtam | 3ac4c3f | 2018-06-01 15:31:06 +0300 | [diff] [blame] | 42 | # omit the version and the num test cases skipped from the summary - this way the output will change less often |
| 43 | set(common_args COMMAND $<TARGET_FILE:${PROJECT_NAME}> --no-skipped-summary --no-version --reporters=console) |
onqtam | 7630535 | 2017-05-01 20:25:09 +0300 | [diff] [blame] | 44 | |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 45 | # add per-file tests |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 46 | foreach(f ${files_with_output}) |
onqtam | 5dbcb1e | 2017-05-02 23:07:56 +0300 | [diff] [blame] | 47 | doctest_add_test(NAME ${f} ${common_args} -sf=*${f}) |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 48 | endforeach() |
| 49 | |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 50 | # add this separately since it shouldn't have output compared to reference output - due to concurrency |
onqtam | 7b7bb8a | 2018-08-17 16:20:16 +0300 | [diff] [blame] | 51 | # not adding it for MinGW since it crashes when using mingw-w64-x86_64-8.1.0-release-posix-seh-rt_v6-rev0 |
onqtam | b031dd0 | 2019-01-15 20:25:19 +0200 | [diff] [blame] | 52 | # (also disabled for old XCode builds on travis where there is no thread_local support and this is defined in the build matrix) |
onqtam | eb89a02 | 2019-01-14 00:16:11 +0200 | [diff] [blame] | 53 | if(NOT MINGW AND NOT DEFINED DOCTEST_THREAD_LOCAL) |
onqtam | 7b7bb8a | 2018-08-17 16:20:16 +0300 | [diff] [blame] | 54 | doctest_add_test(NO_OUTPUT NAME concurrency.cpp ${common_args} -sf=*concurrency.cpp) |
| 55 | endif() |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 56 | |
onqtam | 3ac4c3f | 2018-06-01 15:31:06 +0300 | [diff] [blame] | 57 | # add this separately since the file has a non-straightforward path |
| 58 | doctest_add_test(NAME coverage_maxout.cpp ${common_args} -sf=*coverage_maxout.cpp) |
| 59 | |
onqtam | 7630535 | 2017-05-01 20:25:09 +0300 | [diff] [blame] | 60 | # queries |
onqtam | f6370e2 | 2017-05-03 06:38:27 +0300 | [diff] [blame] | 61 | doctest_add_test(NAME version COMMAND $<TARGET_FILE:${PROJECT_NAME}> -v) |
onqtam | 5dbcb1e | 2017-05-02 23:07:56 +0300 | [diff] [blame] | 62 | doctest_add_test(NAME help ${common_args} -h) |
| 63 | doctest_add_test(NAME count ${common_args} -c -sf=*coverage*) |
| 64 | doctest_add_test(NAME list_test_cases ${common_args} -ltc -sf=*coverage*) |
| 65 | doctest_add_test(NAME list_test_suites ${common_args} -lts -sf=*coverage*) |
onqtam | 3ac4c3f | 2018-06-01 15:31:06 +0300 | [diff] [blame] | 66 | doctest_add_test(NAME list_reporters ${common_args} -lr -sf=*coverage*) |
onqtam | 321f270 | 2017-05-01 19:14:58 +0300 | [diff] [blame] | 67 | |
onqtam | 89da654 | 2017-05-02 21:10:42 +0300 | [diff] [blame] | 68 | # options |
onqtam | 5dbcb1e | 2017-05-02 23:07:56 +0300 | [diff] [blame] | 69 | doctest_add_test(NAME all_binary ${common_args} -tc=all?binary* -s) # print all binary asserts - for getAssertString() |
| 70 | doctest_add_test(NAME abort_after ${common_args} -aa=2 -e=off -sf=*coverage*) # abort after 2 assert fails and parse a negative |
| 71 | doctest_add_test(NAME first_last ${common_args} -f=2 -l=4 -sf=*coverage*) # run a range |
onqtam | 14ddb1e | 2017-05-02 23:19:09 +0300 | [diff] [blame] | 72 | doctest_add_test(NAME filter_1 ${common_args} -ts=none) # should filter out all |
onqtam | f6370e2 | 2017-05-03 06:38:27 +0300 | [diff] [blame] | 73 | doctest_add_test(NAME filter_2 COMMAND $<TARGET_FILE:${PROJECT_NAME}> -tse=* -nv) # should filter out all + print skipped |
onqtam | 14ddb1e | 2017-05-02 23:19:09 +0300 | [diff] [blame] | 74 | doctest_add_test(NAME filter_3 ${common_args} -sc=from*,sc* -sce=sc2 -sf=*subcases*) # enter a specific subcase - sc1 |
onqtam | e6412e1 | 2017-05-07 16:21:36 +0300 | [diff] [blame] | 75 | doctest_add_test(NAME order_1 ${common_args} -ob=suite -ns -sf=*test_cases_and_suites*) |
onqtam | 14ddb1e | 2017-05-02 23:19:09 +0300 | [diff] [blame] | 76 | doctest_add_test(NAME order_2 ${common_args} -ob=name -sf=*test_cases_and_suites*) |
| 77 | doctest_add_test(NAME order_3 ${common_args} -ob=rand -sfe=*) # exclude everything for no output |
onqtam | e0f1880 | 2017-04-16 23:38:33 +0300 | [diff] [blame] | 78 | |
onqtam | 7cc0e96 | 2017-04-17 23:30:36 +0300 | [diff] [blame] | 79 | ################################################################################ |
| 80 | ## VARIATION OF THE BUILD WITH DOCTEST DISABLED - SHOULD STILL COMPILE |
| 81 | ################################################################################ |
| 82 | |
onqtam | aec53d2 | 2017-05-03 06:29:47 +0300 | [diff] [blame] | 83 | if(DEFINED ENV{CODE_COVERAGE}) |
| 84 | return() # do not continue with the disabled example |
| 85 | endif() |
onqtam | f6d1a51 | 2017-05-01 13:56:12 +0300 | [diff] [blame] | 86 | |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 87 | doctest_add_executable(disabled ${files_all}) |
onqtam | e0f1880 | 2017-04-16 23:38:33 +0300 | [diff] [blame] | 88 | target_compile_definitions(disabled PRIVATE DOCTEST_CONFIG_DISABLE) |
onqtam | 7cc0e96 | 2017-04-17 23:30:36 +0300 | [diff] [blame] | 89 | |
onqtam | e0f1880 | 2017-04-16 23:38:33 +0300 | [diff] [blame] | 90 | doctest_add_test(NAME disabled COMMAND $<TARGET_FILE:disabled>) |
onqtam | 7cc0e96 | 2017-04-17 23:30:36 +0300 | [diff] [blame] | 91 | |
onqtam | d320ac2 | 2017-04-17 11:44:32 +0300 | [diff] [blame] | 92 | # TODO: think about fixing these in a different way! - see issue #61 or commit 6b61e8aa3818c5ea100cedc1bb48a60ea10df6e8 |
Martin Moene | d8a7edc | 2017-08-01 17:08:08 +0200 | [diff] [blame] | 93 | if(MSVC) |
onqtam | d320ac2 | 2017-04-17 11:44:32 +0300 | [diff] [blame] | 94 | target_compile_options(disabled PRIVATE /wd4505) # unreferenced local function has been removed |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 95 | target_compile_options(disabled PRIVATE /wd4100) # unreferenced formal parameter |
onqtam | af07cbb | 2017-04-19 19:40:43 +0300 | [diff] [blame] | 96 | target_compile_options(disabled PRIVATE /wd4189) # local variable is initialized but not referenced |
onqtam | d320ac2 | 2017-04-17 11:44:32 +0300 | [diff] [blame] | 97 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
onqtam | 135a50e | 2017-04-18 11:48:20 +0300 | [diff] [blame] | 98 | target_compile_options(disabled PRIVATE -Wno-unknown-warning-option) |
onqtam | d320ac2 | 2017-04-17 11:44:32 +0300 | [diff] [blame] | 99 | target_compile_options(disabled PRIVATE -Wno-unneeded-internal-declaration) |
onqtam | a82c1e4 | 2017-05-07 17:36:41 +0300 | [diff] [blame] | 100 | target_compile_options(disabled PRIVATE -Wno-unused-function) |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 101 | target_compile_options(disabled PRIVATE -Wno-unused-parameter) |
onqtam | c79b754 | 2017-04-19 20:47:13 +0300 | [diff] [blame] | 102 | target_compile_options(disabled PRIVATE -Wno-unused-variable) |
onqtam | eb96d16 | 2017-09-11 14:26:32 +0300 | [diff] [blame] | 103 | target_compile_options(disabled PRIVATE -Wno-unused-template) |
onqtam | c79b754 | 2017-04-19 20:47:13 +0300 | [diff] [blame] | 104 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 105 | target_compile_options(disabled PRIVATE -Wno-unused-function) |
onqtam | c79b754 | 2017-04-19 20:47:13 +0300 | [diff] [blame] | 106 | target_compile_options(disabled PRIVATE -Wno-unused-parameter) |
onqtam | af07cbb | 2017-04-19 19:40:43 +0300 | [diff] [blame] | 107 | target_compile_options(disabled PRIVATE -Wno-unused-variable) |
onqtam | d320ac2 | 2017-04-17 11:44:32 +0300 | [diff] [blame] | 108 | endif() |