Kosta | ce441a9 | 2013-08-05 12:40:33 +0200 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8) |
| 2 | |
Phil Nash | 0bcae64 | 2017-01-09 17:32:57 +0000 | [diff] [blame] | 3 | project(CatchSelfTest) |
Kosta | ce441a9 | 2013-08-05 12:40:33 +0200 | [diff] [blame] | 4 | |
Phil Nash | 8abe17a | 2017-01-09 16:27:06 +0000 | [diff] [blame] | 5 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 6 | |
Kosta | ce441a9 | 2013-08-05 12:40:33 +0200 | [diff] [blame] | 7 | # define some folders |
Phil Nash | c8fefc4 | 2017-01-06 16:19:20 +0000 | [diff] [blame] | 8 | set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
Kosta | ce441a9 | 2013-08-05 12:40:33 +0200 | [diff] [blame] | 9 | set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest) |
Phil Nash | e1fbbe1 | 2017-01-06 16:59:18 +0000 | [diff] [blame] | 10 | set(HEADER_DIR ${CATCH_DIR}/include) |
| 11 | |
Andy Sawyer | 13cbdf7 | 2014-09-04 00:32:05 +0100 | [diff] [blame] | 12 | if(USE_CPP11) |
Phil Nash | 30cebd6 | 2016-11-09 22:55:32 +0000 | [diff] [blame] | 13 | ## We can't turn this on by default, since it breaks on travis |
| 14 | message(STATUS "Enabling C++11") |
| 15 | set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") |
Martin Hořeňovský | e6ef60a | 2017-01-15 22:07:36 +0100 | [diff] [blame] | 16 | elseif(USE_CPP14) |
| 17 | message(STATUS "Enabling C++14") |
| 18 | set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}") |
Andy Sawyer | 13cbdf7 | 2014-09-04 00:32:05 +0100 | [diff] [blame] | 19 | endif() |
Kosta | ce441a9 | 2013-08-05 12:40:33 +0200 | [diff] [blame] | 20 | |
Martin Hořeňovský | e6ef60a | 2017-01-15 22:07:36 +0100 | [diff] [blame] | 21 | #checks that the given hard-coded list contains all headers + sources in the given folder |
| 22 | function(CheckFileList LIST_VAR FOLDER) |
| 23 | set(MESSAGE " should be added to the variable ${LIST_VAR}") |
| 24 | set(MESSAGE "${MESSAGE} in ${CMAKE_CURRENT_LIST_FILE}\n") |
| 25 | file(GLOB GLOBBED_LIST "${FOLDER}/*.cpp" |
| 26 | "${FOLDER}/*.hpp" |
| 27 | "${FOLDER}/*.h") |
| 28 | list(REMOVE_ITEM GLOBBED_LIST ${${LIST_VAR}}) |
| 29 | foreach(EXTRA_ITEM ${GLOBBED_LIST}) |
| 30 | string(REPLACE "${CATCH_DIR}/" "" RELATIVE_FILE_NAME "${EXTRA_ITEM}") |
| 31 | message(AUTHOR_WARNING "The file \"${RELATIVE_FILE_NAME}\"${MESSAGE}") |
| 32 | endforeach() |
| 33 | endfunction() |
| 34 | |
| 35 | function(CheckFileListRec LIST_VAR FOLDER) |
| 36 | set(MESSAGE " should be added to the variable ${LIST_VAR}") |
| 37 | set(MESSAGE "${MESSAGE} in ${CMAKE_CURRENT_LIST_FILE}\n") |
| 38 | file(GLOB_RECURSE GLOBBED_LIST "${FOLDER}/*.cpp" |
| 39 | "${FOLDER}/*.hpp" |
| 40 | "${FOLDER}/*.h") |
| 41 | list(REMOVE_ITEM GLOBBED_LIST ${${LIST_VAR}}) |
| 42 | foreach(EXTRA_ITEM ${GLOBBED_LIST}) |
| 43 | string(REPLACE "${CATCH_DIR}/" "" RELATIVE_FILE_NAME "${EXTRA_ITEM}") |
| 44 | message(AUTHOR_WARNING "The file \"${RELATIVE_FILE_NAME}\"${MESSAGE}") |
| 45 | endforeach() |
| 46 | endfunction() |
| 47 | |
Kosta | ce441a9 | 2013-08-05 12:40:33 +0200 | [diff] [blame] | 48 | # define the sources of the self test |
Phil Nash | d5360e8 | 2017-01-12 11:54:53 +0000 | [diff] [blame] | 49 | # Please keep these ordered alphabetically |
Phil Nash | 8abe17a | 2017-01-09 16:27:06 +0000 | [diff] [blame] | 50 | set(TEST_SOURCES |
Phil Nash | 30cebd6 | 2016-11-09 22:55:32 +0000 | [diff] [blame] | 51 | ${SELF_TEST_DIR}/ApproxTests.cpp |
| 52 | ${SELF_TEST_DIR}/BDDTests.cpp |
| 53 | ${SELF_TEST_DIR}/ClassTests.cpp |
Phil Nash | d5360e8 | 2017-01-12 11:54:53 +0000 | [diff] [blame] | 54 | ${SELF_TEST_DIR}/CmdLineTests.cpp |
Phil Nash | 30cebd6 | 2016-11-09 22:55:32 +0000 | [diff] [blame] | 55 | ${SELF_TEST_DIR}/ConditionTests.cpp |
Phil Nash | d5360e8 | 2017-01-12 11:54:53 +0000 | [diff] [blame] | 56 | ${SELF_TEST_DIR}/EnumToString.cpp |
Phil Nash | 30cebd6 | 2016-11-09 22:55:32 +0000 | [diff] [blame] | 57 | ${SELF_TEST_DIR}/ExceptionTests.cpp |
| 58 | ${SELF_TEST_DIR}/GeneratorTests.cpp |
| 59 | ${SELF_TEST_DIR}/MessageTests.cpp |
| 60 | ${SELF_TEST_DIR}/MiscTests.cpp |
| 61 | ${SELF_TEST_DIR}/PartTrackerTests.cpp |
Phil Nash | d5360e8 | 2017-01-12 11:54:53 +0000 | [diff] [blame] | 62 | ${SELF_TEST_DIR}/TagAliasTests.cpp |
Phil Nash | 30cebd6 | 2016-11-09 22:55:32 +0000 | [diff] [blame] | 63 | ${SELF_TEST_DIR}/TestMain.cpp |
Phil Nash | 30cebd6 | 2016-11-09 22:55:32 +0000 | [diff] [blame] | 64 | ${SELF_TEST_DIR}/ToStringPair.cpp |
Phil Nash | d5360e8 | 2017-01-12 11:54:53 +0000 | [diff] [blame] | 65 | ${SELF_TEST_DIR}/ToStringTuple.cpp |
Phil Nash | 30cebd6 | 2016-11-09 22:55:32 +0000 | [diff] [blame] | 66 | ${SELF_TEST_DIR}/ToStringVector.cpp |
| 67 | ${SELF_TEST_DIR}/ToStringWhich.cpp |
Phil Nash | d5360e8 | 2017-01-12 11:54:53 +0000 | [diff] [blame] | 68 | ${SELF_TEST_DIR}/TrickyTests.cpp |
| 69 | ${SELF_TEST_DIR}/VariadicMacrosTests.cpp |
Phil Nash | 8abe17a | 2017-01-09 16:27:06 +0000 | [diff] [blame] | 70 | ) |
Martin Hořeňovský | e6ef60a | 2017-01-15 22:07:36 +0100 | [diff] [blame] | 71 | CheckFileList(TEST_SOURCES ${SELF_TEST_DIR}) |
Phil Nash | d5360e8 | 2017-01-12 11:54:53 +0000 | [diff] [blame] | 72 | |
| 73 | # A set of impl files that just #include a single header |
| 74 | # Please keep these ordered alphabetically |
Phil Nash | 8abe17a | 2017-01-09 16:27:06 +0000 | [diff] [blame] | 75 | set(IMPL_SOURCES |
Phil Nash | 30cebd6 | 2016-11-09 22:55:32 +0000 | [diff] [blame] | 76 | ${SELF_TEST_DIR}/SurrogateCpps/catch_common.cpp |
| 77 | ${SELF_TEST_DIR}/SurrogateCpps/catch_console_colour.cpp |
| 78 | ${SELF_TEST_DIR}/SurrogateCpps/catch_debugger.cpp |
| 79 | ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_capture.cpp |
| 80 | ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_config.cpp |
| 81 | ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_exception.cpp |
| 82 | ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_generators.cpp |
| 83 | ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_registry_hub.cpp |
| 84 | ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_reporter.cpp |
| 85 | ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_runner.cpp |
| 86 | ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_testcase.cpp |
| 87 | ${SELF_TEST_DIR}/SurrogateCpps/catch_message.cpp |
| 88 | ${SELF_TEST_DIR}/SurrogateCpps/catch_option.cpp |
| 89 | ${SELF_TEST_DIR}/SurrogateCpps/catch_ptr.cpp |
| 90 | ${SELF_TEST_DIR}/SurrogateCpps/catch_stream.cpp |
| 91 | ${SELF_TEST_DIR}/SurrogateCpps/catch_streambuf.cpp |
| 92 | ${SELF_TEST_DIR}/SurrogateCpps/catch_test_spec.cpp |
| 93 | ${SELF_TEST_DIR}/SurrogateCpps/catch_xmlwriter.cpp |
Phil Nash | 876af87 | 2017-01-23 15:18:23 +0000 | [diff] [blame^] | 94 | ${SELF_TEST_DIR}/SurrogateCpps/catch_test_case_tracker.cpp |
Phil Nash | 30cebd6 | 2016-11-09 22:55:32 +0000 | [diff] [blame] | 95 | ) |
Martin Hořeňovský | e6ef60a | 2017-01-15 22:07:36 +0100 | [diff] [blame] | 96 | CheckFileList(IMPL_SOURCES ${SELF_TEST_DIR}/SurrogateCpps) |
Kosta | ce441a9 | 2013-08-05 12:40:33 +0200 | [diff] [blame] | 97 | |
Martin Hořeňovský | e6ef60a | 2017-01-15 22:07:36 +0100 | [diff] [blame] | 98 | |
Phil Nash | d5360e8 | 2017-01-12 11:54:53 +0000 | [diff] [blame] | 99 | # Please keep these ordered alphabetically |
Martin Hořeňovský | e6ef60a | 2017-01-15 22:07:36 +0100 | [diff] [blame] | 100 | set(TOP_LEVEL_HEADERS |
Phil Nash | e1fbbe1 | 2017-01-06 16:59:18 +0000 | [diff] [blame] | 101 | ${HEADER_DIR}/catch.hpp |
| 102 | ${HEADER_DIR}/catch_session.hpp |
| 103 | ${HEADER_DIR}/catch_with_main.hpp |
Martin Hořeňovský | e6ef60a | 2017-01-15 22:07:36 +0100 | [diff] [blame] | 104 | ) |
| 105 | CheckFileList(TOP_LEVEL_HEADERS ${HEADER_DIR}) |
| 106 | |
| 107 | # Please keep these ordered alphabetically |
| 108 | set(EXTERNAL_HEADERS |
Phil Nash | d5360e8 | 2017-01-12 11:54:53 +0000 | [diff] [blame] | 109 | ${HEADER_DIR}/external/clara.h |
| 110 | ${HEADER_DIR}/external/tbc_text_format.h |
Martin Hořeňovský | e6ef60a | 2017-01-15 22:07:36 +0100 | [diff] [blame] | 111 | ) |
| 112 | CheckFileList(EXTERNAL_HEADERS ${HEADER_DIR}/external) |
| 113 | |
| 114 | |
| 115 | # Please keep these ordered alphabetically |
| 116 | set(INTERNAL_HEADERS |
Phil Nash | e1fbbe1 | 2017-01-06 16:59:18 +0000 | [diff] [blame] | 117 | ${HEADER_DIR}/internal/catch_approx.hpp |
| 118 | ${HEADER_DIR}/internal/catch_assertionresult.h |
| 119 | ${HEADER_DIR}/internal/catch_assertionresult.hpp |
| 120 | ${HEADER_DIR}/internal/catch_capture.hpp |
| 121 | ${HEADER_DIR}/internal/catch_clara.h |
| 122 | ${HEADER_DIR}/internal/catch_commandline.hpp |
| 123 | ${HEADER_DIR}/internal/catch_common.h |
| 124 | ${HEADER_DIR}/internal/catch_common.hpp |
| 125 | ${HEADER_DIR}/internal/catch_compiler_capabilities.h |
| 126 | ${HEADER_DIR}/internal/catch_config.hpp |
| 127 | ${HEADER_DIR}/internal/catch_console_colour.hpp |
| 128 | ${HEADER_DIR}/internal/catch_console_colour_impl.hpp |
| 129 | ${HEADER_DIR}/internal/catch_context.h |
| 130 | ${HEADER_DIR}/internal/catch_context_impl.hpp |
| 131 | ${HEADER_DIR}/internal/catch_debugger.h |
| 132 | ${HEADER_DIR}/internal/catch_debugger.hpp |
| 133 | ${HEADER_DIR}/internal/catch_default_main.hpp |
| 134 | ${HEADER_DIR}/internal/catch_evaluate.hpp |
| 135 | ${HEADER_DIR}/internal/catch_exception_translator_registry.hpp |
| 136 | ${HEADER_DIR}/internal/catch_expression_lhs.hpp |
| 137 | ${HEADER_DIR}/internal/catch_fatal_condition.hpp |
| 138 | ${HEADER_DIR}/internal/catch_generators.hpp |
| 139 | ${HEADER_DIR}/internal/catch_generators_impl.hpp |
| 140 | ${HEADER_DIR}/internal/catch_impl.hpp |
| 141 | ${HEADER_DIR}/internal/catch_interfaces_capture.h |
| 142 | ${HEADER_DIR}/internal/catch_interfaces_config.h |
| 143 | ${HEADER_DIR}/internal/catch_interfaces_exception.h |
| 144 | ${HEADER_DIR}/internal/catch_interfaces_generators.h |
| 145 | ${HEADER_DIR}/internal/catch_interfaces_registry_hub.h |
| 146 | ${HEADER_DIR}/internal/catch_interfaces_reporter.h |
| 147 | ${HEADER_DIR}/internal/catch_interfaces_runner.h |
| 148 | ${HEADER_DIR}/internal/catch_interfaces_tag_alias_registry.h |
| 149 | ${HEADER_DIR}/internal/catch_interfaces_testcase.h |
| 150 | ${HEADER_DIR}/internal/catch_legacy_reporter_adapter.h |
| 151 | ${HEADER_DIR}/internal/catch_legacy_reporter_adapter.hpp |
| 152 | ${HEADER_DIR}/internal/catch_list.hpp |
| 153 | ${HEADER_DIR}/internal/catch_matchers.hpp |
| 154 | ${HEADER_DIR}/internal/catch_message.h |
| 155 | ${HEADER_DIR}/internal/catch_message.hpp |
| 156 | ${HEADER_DIR}/internal/catch_notimplemented_exception.h |
| 157 | ${HEADER_DIR}/internal/catch_notimplemented_exception.hpp |
| 158 | ${HEADER_DIR}/internal/catch_objc.hpp |
| 159 | ${HEADER_DIR}/internal/catch_objc_arc.hpp |
| 160 | ${HEADER_DIR}/internal/catch_option.hpp |
| 161 | ${HEADER_DIR}/internal/catch_platform.h |
| 162 | ${HEADER_DIR}/internal/catch_ptr.hpp |
| 163 | ${HEADER_DIR}/internal/catch_reenable_warnings.h |
| 164 | ${HEADER_DIR}/internal/catch_registry_hub.hpp |
| 165 | ${HEADER_DIR}/internal/catch_reporter_registrars.hpp |
| 166 | ${HEADER_DIR}/internal/catch_reporter_registry.hpp |
| 167 | ${HEADER_DIR}/internal/catch_result_builder.h |
| 168 | ${HEADER_DIR}/internal/catch_result_builder.hpp |
| 169 | ${HEADER_DIR}/internal/catch_result_type.h |
| 170 | ${HEADER_DIR}/internal/catch_run_context.hpp |
| 171 | ${HEADER_DIR}/internal/catch_section.h |
| 172 | ${HEADER_DIR}/internal/catch_section.hpp |
| 173 | ${HEADER_DIR}/internal/catch_section_info.h |
| 174 | ${HEADER_DIR}/internal/catch_section_info.hpp |
| 175 | ${HEADER_DIR}/internal/catch_stream.h |
| 176 | ${HEADER_DIR}/internal/catch_stream.hpp |
| 177 | ${HEADER_DIR}/internal/catch_streambuf.h |
| 178 | ${HEADER_DIR}/internal/catch_suppress_warnings.h |
| 179 | ${HEADER_DIR}/internal/catch_tag_alias.h |
| 180 | ${HEADER_DIR}/internal/catch_tag_alias_registry.h |
| 181 | ${HEADER_DIR}/internal/catch_tag_alias_registry.hpp |
| 182 | ${HEADER_DIR}/internal/catch_test_case_info.h |
| 183 | ${HEADER_DIR}/internal/catch_test_case_info.hpp |
| 184 | ${HEADER_DIR}/internal/catch_test_case_registry_impl.hpp |
| 185 | ${HEADER_DIR}/internal/catch_test_case_tracker.hpp |
| 186 | ${HEADER_DIR}/internal/catch_test_registry.hpp |
| 187 | ${HEADER_DIR}/internal/catch_test_spec.hpp |
| 188 | ${HEADER_DIR}/internal/catch_test_spec_parser.hpp |
| 189 | ${HEADER_DIR}/internal/catch_text.h |
| 190 | ${HEADER_DIR}/internal/catch_timer.h |
| 191 | ${HEADER_DIR}/internal/catch_timer.hpp |
| 192 | ${HEADER_DIR}/internal/catch_tostring.h |
| 193 | ${HEADER_DIR}/internal/catch_tostring.hpp |
| 194 | ${HEADER_DIR}/internal/catch_totals.hpp |
| 195 | ${HEADER_DIR}/internal/catch_version.h |
| 196 | ${HEADER_DIR}/internal/catch_version.hpp |
| 197 | ${HEADER_DIR}/internal/catch_wildcard_pattern.hpp |
Martin Hořeňovský | 531d267 | 2017-01-16 19:56:57 +0100 | [diff] [blame] | 198 | ${HEADER_DIR}/internal/catch_windows_h_proxy.h |
Phil Nash | e1fbbe1 | 2017-01-06 16:59:18 +0000 | [diff] [blame] | 199 | ${HEADER_DIR}/internal/catch_xmlwriter.hpp |
Martin Hořeňovský | e6ef60a | 2017-01-15 22:07:36 +0100 | [diff] [blame] | 200 | ) |
| 201 | CheckFileList(INTERNAL_HEADERS ${HEADER_DIR}/internal) |
| 202 | |
| 203 | # Please keep these ordered alphabetically |
| 204 | set(REPORTER_HEADERS |
Phil Nash | e1fbbe1 | 2017-01-06 16:59:18 +0000 | [diff] [blame] | 205 | ${HEADER_DIR}/reporters/catch_reporter_bases.hpp |
| 206 | ${HEADER_DIR}/reporters/catch_reporter_compact.hpp |
| 207 | ${HEADER_DIR}/reporters/catch_reporter_console.hpp |
| 208 | ${HEADER_DIR}/reporters/catch_reporter_junit.hpp |
| 209 | ${HEADER_DIR}/reporters/catch_reporter_multi.hpp |
| 210 | ${HEADER_DIR}/reporters/catch_reporter_teamcity.hpp |
| 211 | ${HEADER_DIR}/reporters/catch_reporter_xml.hpp |
| 212 | ) |
Martin Hořeňovský | e6ef60a | 2017-01-15 22:07:36 +0100 | [diff] [blame] | 213 | CheckFileList(REPORTER_HEADERS ${HEADER_DIR}/reporters) |
| 214 | |
| 215 | # Specify the headers, too, so CLion recognises them as project files |
| 216 | set(HEADERS |
| 217 | ${TOP_LEVEL_HEADERS} |
| 218 | ${EXTERNAL_HEADERS} |
| 219 | ${INTERNAL_HEADERS} |
| 220 | ${REPORTER_HEADERS} |
| 221 | ) |
| 222 | |
Phil Nash | e1fbbe1 | 2017-01-06 16:59:18 +0000 | [diff] [blame] | 223 | |
Phil Nash | d5360e8 | 2017-01-12 11:54:53 +0000 | [diff] [blame] | 224 | # Provide some groupings for IDEs |
Phil Nash | 8abe17a | 2017-01-09 16:27:06 +0000 | [diff] [blame] | 225 | SOURCE_GROUP("Tests" FILES ${TEST_SOURCES}) |
| 226 | SOURCE_GROUP("Surrogates" FILES ${IMPL_SOURCES}) |
| 227 | |
Kosta | ce441a9 | 2013-08-05 12:40:33 +0200 | [diff] [blame] | 228 | # configure the executable |
Phil Nash | e1fbbe1 | 2017-01-06 16:59:18 +0000 | [diff] [blame] | 229 | include_directories(${HEADER_DIR}) |
Phil Nash | 8abe17a | 2017-01-09 16:27:06 +0000 | [diff] [blame] | 230 | add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${HEADERS}) |
Kosta | ce441a9 | 2013-08-05 12:40:33 +0200 | [diff] [blame] | 231 | |
Fraser Hutchison | 69a3f16 | 2013-10-24 02:57:46 +0100 | [diff] [blame] | 232 | # configure unit tests via CTest |
Kosta | ce441a9 | 2013-08-05 12:40:33 +0200 | [diff] [blame] | 233 | enable_testing() |
Fraser Hutchison | 69a3f16 | 2013-10-24 02:57:46 +0100 | [diff] [blame] | 234 | add_test(NAME RunTests COMMAND SelfTest) |
| 235 | |
| 236 | add_test(NAME ListTests COMMAND SelfTest --list-tests) |
| 237 | set_tests_properties(ListTests PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ test cases") |
| 238 | |
| 239 | add_test(NAME ListTags COMMAND SelfTest --list-tags) |
| 240 | set_tests_properties(ListTags PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ tags") |