blob: a13e100b9ed67c5a9fcfcf7d8fa819d8fa55d38a [file] [log] [blame]
Martin Hořeňovský50c95a02017-01-31 20:21:03 +01001cmake_minimum_required(VERSION 3.0)
Kostace441a92013-08-05 12:40:33 +02002
Phil Nash0bcae642017-01-09 17:32:57 +00003project(CatchSelfTest)
Kostace441a92013-08-05 12:40:33 +02004
Martin Hořeňovskýa20b2862017-11-05 12:46:04 +01005option(USE_VALGRIND "Perform SelfTests with Valgrind" OFF)
6
Phil Nash8abe17a2017-01-09 16:27:06 +00007set_property(GLOBAL PROPERTY USE_FOLDERS ON)
8
Kostace441a92013-08-05 12:40:33 +02009# define some folders
Phil Nashc8fefc42017-01-06 16:19:20 +000010set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Kostace441a92013-08-05 12:40:33 +020011set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest)
Martin Hořeňovský3b7511e2017-01-14 21:55:37 +010012set(BENCHMARK_DIR ${CATCH_DIR}/projects/Benchmark)
Phil Nashe1fbbe12017-01-06 16:59:18 +000013set(HEADER_DIR ${CATCH_DIR}/include)
Phil Nashb119ebd2017-11-03 12:01:52 +000014set(CATCH_VERSION_NUMBER 2.0.1)
Phil Nashe1fbbe12017-01-06 16:59:18 +000015
Antonio Di Monacob8443e62017-05-11 13:00:03 +020016if(USE_WMAIN)
17 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:wmainCRTStartup")
18endif()
19
Martin Hořeňovskýe6ef60a2017-01-15 22:07:36 +010020#checks that the given hard-coded list contains all headers + sources in the given folder
21function(CheckFileList LIST_VAR FOLDER)
22 set(MESSAGE " should be added to the variable ${LIST_VAR}")
23 set(MESSAGE "${MESSAGE} in ${CMAKE_CURRENT_LIST_FILE}\n")
24 file(GLOB GLOBBED_LIST "${FOLDER}/*.cpp"
25 "${FOLDER}/*.hpp"
26 "${FOLDER}/*.h")
27 list(REMOVE_ITEM GLOBBED_LIST ${${LIST_VAR}})
28 foreach(EXTRA_ITEM ${GLOBBED_LIST})
29 string(REPLACE "${CATCH_DIR}/" "" RELATIVE_FILE_NAME "${EXTRA_ITEM}")
30 message(AUTHOR_WARNING "The file \"${RELATIVE_FILE_NAME}\"${MESSAGE}")
31 endforeach()
32endfunction()
33
34function(CheckFileListRec LIST_VAR FOLDER)
35 set(MESSAGE " should be added to the variable ${LIST_VAR}")
36 set(MESSAGE "${MESSAGE} in ${CMAKE_CURRENT_LIST_FILE}\n")
37 file(GLOB_RECURSE GLOBBED_LIST "${FOLDER}/*.cpp"
38 "${FOLDER}/*.hpp"
39 "${FOLDER}/*.h")
40 list(REMOVE_ITEM GLOBBED_LIST ${${LIST_VAR}})
41 foreach(EXTRA_ITEM ${GLOBBED_LIST})
42 string(REPLACE "${CATCH_DIR}/" "" RELATIVE_FILE_NAME "${EXTRA_ITEM}")
43 message(AUTHOR_WARNING "The file \"${RELATIVE_FILE_NAME}\"${MESSAGE}")
44 endforeach()
45endfunction()
46
Kostace441a92013-08-05 12:40:33 +020047# define the sources of the self test
Phil Nashd5360e82017-01-12 11:54:53 +000048# Please keep these ordered alphabetically
Phil Nash8abe17a2017-01-09 16:27:06 +000049set(TEST_SOURCES
Phil Nash30cebd62016-11-09 22:55:32 +000050 ${SELF_TEST_DIR}/ApproxTests.cpp
51 ${SELF_TEST_DIR}/BDDTests.cpp
Phil Nashf45d35c2017-08-05 11:12:29 +010052 ${SELF_TEST_DIR}/Benchmark.tests.cpp
Phil Nash30cebd62016-11-09 22:55:32 +000053 ${SELF_TEST_DIR}/ClassTests.cpp
Phil Nashd5360e82017-01-12 11:54:53 +000054 ${SELF_TEST_DIR}/CmdLineTests.cpp
Martin Hořeňovský7db4d8d2017-02-07 13:32:48 +010055 ${SELF_TEST_DIR}/CompilationTests.cpp
Phil Nash30cebd62016-11-09 22:55:32 +000056 ${SELF_TEST_DIR}/ConditionTests.cpp
Martin Hořeňovskýea48ae02017-05-27 14:42:05 +020057 ${SELF_TEST_DIR}/DecompositionTests.cpp
Phil Nashd5360e82017-01-12 11:54:53 +000058 ${SELF_TEST_DIR}/EnumToString.cpp
Phil Nash30cebd62016-11-09 22:55:32 +000059 ${SELF_TEST_DIR}/ExceptionTests.cpp
Phil Nash30cebd62016-11-09 22:55:32 +000060 ${SELF_TEST_DIR}/MessageTests.cpp
61 ${SELF_TEST_DIR}/MiscTests.cpp
62 ${SELF_TEST_DIR}/PartTrackerTests.cpp
Phil Nashd5360e82017-01-12 11:54:53 +000063 ${SELF_TEST_DIR}/TagAliasTests.cpp
Phil Nash30cebd62016-11-09 22:55:32 +000064 ${SELF_TEST_DIR}/TestMain.cpp
Martin Hořeňovský79b405f2017-10-09 12:31:22 +020065 ${SELF_TEST_DIR}/ToStringChrono.cpp
Martin Hořeňovský7db4d8d2017-02-07 13:32:48 +010066 ${SELF_TEST_DIR}/ToStringGeneralTests.cpp
Phil Nash30cebd62016-11-09 22:55:32 +000067 ${SELF_TEST_DIR}/ToStringPair.cpp
Phil Nashd5360e82017-01-12 11:54:53 +000068 ${SELF_TEST_DIR}/ToStringTuple.cpp
Phil Nash30cebd62016-11-09 22:55:32 +000069 ${SELF_TEST_DIR}/ToStringVector.cpp
70 ${SELF_TEST_DIR}/ToStringWhich.cpp
Phil Nashd5360e82017-01-12 11:54:53 +000071 ${SELF_TEST_DIR}/TrickyTests.cpp
72 ${SELF_TEST_DIR}/VariadicMacrosTests.cpp
Phil Nash4e6938d2017-02-21 14:19:09 +000073 ${SELF_TEST_DIR}/MatchersTests.cpp
Phil Nash78e79942017-06-29 11:18:14 +010074 ${SELF_TEST_DIR}/StringRef.tests.cpp
Phil Nash8abe17a2017-01-09 16:27:06 +000075 )
Martin Hořeňovskýe6ef60a2017-01-15 22:07:36 +010076CheckFileList(TEST_SOURCES ${SELF_TEST_DIR})
Phil Nashd5360e82017-01-12 11:54:53 +000077
78# A set of impl files that just #include a single header
79# Please keep these ordered alphabetically
Martin Hořeňovskýfc321652017-07-06 22:28:42 +020080set(SURROGATE_SOURCES
Phil Nash30cebd62016-11-09 22:55:32 +000081 ${SELF_TEST_DIR}/SurrogateCpps/catch_console_colour.cpp
82 ${SELF_TEST_DIR}/SurrogateCpps/catch_debugger.cpp
Phil Nash30cebd62016-11-09 22:55:32 +000083 ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_reporter.cpp
Phil Nash30cebd62016-11-09 22:55:32 +000084 ${SELF_TEST_DIR}/SurrogateCpps/catch_option.cpp
Phil Nash30cebd62016-11-09 22:55:32 +000085 ${SELF_TEST_DIR}/SurrogateCpps/catch_stream.cpp
Phil Nashf45d35c2017-08-05 11:12:29 +010086 ${SELF_TEST_DIR}/SurrogateCpps/catch_test_case_tracker.cpp
Phil Nash30cebd62016-11-09 22:55:32 +000087 ${SELF_TEST_DIR}/SurrogateCpps/catch_test_spec.cpp
88 ${SELF_TEST_DIR}/SurrogateCpps/catch_xmlwriter.cpp
89 )
Martin Hořeňovskýfc321652017-07-06 22:28:42 +020090CheckFileList(SURROGATE_SOURCES ${SELF_TEST_DIR}/SurrogateCpps)
Kostace441a92013-08-05 12:40:33 +020091
Martin Hořeňovskýe6ef60a2017-01-15 22:07:36 +010092
Phil Nashd5360e82017-01-12 11:54:53 +000093# Please keep these ordered alphabetically
Martin Hořeňovskýe6ef60a2017-01-15 22:07:36 +010094set(TOP_LEVEL_HEADERS
Phil Nashe1fbbe12017-01-06 16:59:18 +000095 ${HEADER_DIR}/catch.hpp
Phil Nashe1fbbe12017-01-06 16:59:18 +000096 ${HEADER_DIR}/catch_with_main.hpp
Martin Hořeňovskýe6ef60a2017-01-15 22:07:36 +010097 )
98CheckFileList(TOP_LEVEL_HEADERS ${HEADER_DIR})
Martin Hořeňovskýdab1d9d2017-01-25 23:02:25 +010099
Martin Hořeňovskýe6ef60a2017-01-15 22:07:36 +0100100# Please keep these ordered alphabetically
101set(EXTERNAL_HEADERS
Phil Nash1c223b62017-06-12 23:04:24 +0100102 ${HEADER_DIR}/external/clara.hpp
Martin Hořeňovskýe6ef60a2017-01-15 22:07:36 +0100103 )
104CheckFileList(EXTERNAL_HEADERS ${HEADER_DIR}/external)
105
Martin Hořeňovskýdab1d9d2017-01-25 23:02:25 +0100106
Martin Hořeňovskýe6ef60a2017-01-15 22:07:36 +0100107# Please keep these ordered alphabetically
108set(INTERNAL_HEADERS
Phil Nashca7021a2017-09-07 12:58:44 +0100109 ${HEADER_DIR}/internal/catch_approx.h
Phil Nashf247ce52017-08-08 17:53:01 +0100110 ${HEADER_DIR}/internal/catch_assertionhandler.h
111 ${HEADER_DIR}/internal/catch_assertioninfo.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000112 ${HEADER_DIR}/internal/catch_assertionresult.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000113 ${HEADER_DIR}/internal/catch_capture.hpp
Phil Nashee9b19e2017-08-09 12:10:14 +0100114 ${HEADER_DIR}/internal/catch_capture_matchers.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000115 ${HEADER_DIR}/internal/catch_clara.h
Phil Nashca7021a2017-09-07 12:58:44 +0100116 ${HEADER_DIR}/internal/catch_commandline.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000117 ${HEADER_DIR}/internal/catch_common.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000118 ${HEADER_DIR}/internal/catch_compiler_capabilities.h
119 ${HEADER_DIR}/internal/catch_config.hpp
Phil Nashca7021a2017-09-07 12:58:44 +0100120 ${HEADER_DIR}/internal/catch_console_colour.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000121 ${HEADER_DIR}/internal/catch_context.h
Martin Hořeňovský59325762017-08-29 13:51:55 +0200122 ${HEADER_DIR}/internal/catch_debug_console.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000123 ${HEADER_DIR}/internal/catch_debugger.h
Phil Nashf247ce52017-08-08 17:53:01 +0100124 ${HEADER_DIR}/internal/catch_decomposer.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000125 ${HEADER_DIR}/internal/catch_default_main.hpp
Martin Hořeňovskýfeca97d2017-08-01 18:46:33 +0200126 ${HEADER_DIR}/internal/catch_enforce.h
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200127 ${HEADER_DIR}/internal/catch_errno_guard.h
Martin Hořeňovský1d3bfa02017-07-10 14:25:38 +0200128 ${HEADER_DIR}/internal/catch_exception_translator_registry.h
Martin Hořeňovský24af32f2017-08-17 20:21:06 +0200129 ${HEADER_DIR}/internal/catch_external_interfaces.h
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200130 ${HEADER_DIR}/internal/catch_fatal_condition.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000131 ${HEADER_DIR}/internal/catch_impl.hpp
132 ${HEADER_DIR}/internal/catch_interfaces_capture.h
133 ${HEADER_DIR}/internal/catch_interfaces_config.h
134 ${HEADER_DIR}/internal/catch_interfaces_exception.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000135 ${HEADER_DIR}/internal/catch_interfaces_registry_hub.h
136 ${HEADER_DIR}/internal/catch_interfaces_reporter.h
137 ${HEADER_DIR}/internal/catch_interfaces_runner.h
138 ${HEADER_DIR}/internal/catch_interfaces_tag_alias_registry.h
139 ${HEADER_DIR}/internal/catch_interfaces_testcase.h
Martin Hořeňovský4332b842017-07-12 14:47:36 +0200140 ${HEADER_DIR}/internal/catch_leak_detector.h
Martin Hořeňovský1d3bfa02017-07-10 14:25:38 +0200141 ${HEADER_DIR}/internal/catch_list.h
Phil Nashca7021a2017-09-07 12:58:44 +0100142 ${HEADER_DIR}/internal/catch_matchers.h
Martin Hořeňovský0b1f1b12017-11-10 18:14:42 +0100143 ${HEADER_DIR}/internal/catch_matchers_floating.h
Phil Nash14001272017-02-08 15:14:51 +0000144 ${HEADER_DIR}/internal/catch_matchers_string.h
Phil Nash10dfca32017-02-21 16:05:04 +0000145 ${HEADER_DIR}/internal/catch_matchers_vector.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000146 ${HEADER_DIR}/internal/catch_message.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000147 ${HEADER_DIR}/internal/catch_objc.hpp
148 ${HEADER_DIR}/internal/catch_objc_arc.hpp
149 ${HEADER_DIR}/internal/catch_option.hpp
150 ${HEADER_DIR}/internal/catch_platform.h
Martin Hořeňovský0673b9b2017-08-30 15:32:44 +0200151 ${HEADER_DIR}/internal/catch_random_number_generator.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000152 ${HEADER_DIR}/internal/catch_reenable_warnings.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000153 ${HEADER_DIR}/internal/catch_reporter_registrars.hpp
Martin Hořeňovský9aa96712017-09-07 16:51:33 +0200154 ${HEADER_DIR}/internal/catch_reporter_registry.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000155 ${HEADER_DIR}/internal/catch_result_type.h
Phil Nashca7021a2017-09-07 12:58:44 +0100156 ${HEADER_DIR}/internal/catch_run_context.h
Phil Nasha9b68132017-08-04 19:23:30 +0100157 ${HEADER_DIR}/internal/catch_benchmark.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000158 ${HEADER_DIR}/internal/catch_section.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000159 ${HEADER_DIR}/internal/catch_section_info.h
Martin Hořeňovskýe8717422017-08-31 10:31:52 +0200160 ${HEADER_DIR}/internal/catch_session.h
Martin Hořeňovskýda0edcb2017-06-04 21:39:27 +0200161 ${HEADER_DIR}/internal/catch_startup_exception_registry.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000162 ${HEADER_DIR}/internal/catch_stream.h
Phil Nash78e79942017-06-29 11:18:14 +0100163 ${HEADER_DIR}/internal/catch_stringref.h
Martin Hořeňovský1a961752017-07-25 21:57:35 +0200164 ${HEADER_DIR}/internal/catch_string_manip.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000165 ${HEADER_DIR}/internal/catch_suppress_warnings.h
166 ${HEADER_DIR}/internal/catch_tag_alias.h
Martin Hořeňovský33fd54a2017-07-27 11:55:30 +0200167 ${HEADER_DIR}/internal/catch_tag_alias_autoregistrar.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000168 ${HEADER_DIR}/internal/catch_tag_alias_registry.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000169 ${HEADER_DIR}/internal/catch_test_case_info.h
Phil Nashca7021a2017-09-07 12:58:44 +0100170 ${HEADER_DIR}/internal/catch_test_case_registry_impl.h
171 ${HEADER_DIR}/internal/catch_test_case_tracker.h
172 ${HEADER_DIR}/internal/catch_test_registry.h
173 ${HEADER_DIR}/internal/catch_test_spec.h
174 ${HEADER_DIR}/internal/catch_test_spec_parser.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000175 ${HEADER_DIR}/internal/catch_text.h
176 ${HEADER_DIR}/internal/catch_timer.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000177 ${HEADER_DIR}/internal/catch_tostring.h
Phil Nashca7021a2017-09-07 12:58:44 +0100178 ${HEADER_DIR}/internal/catch_totals.h
Phil Nashe1fbbe12017-01-06 16:59:18 +0000179 ${HEADER_DIR}/internal/catch_version.h
Phil Nashca7021a2017-09-07 12:58:44 +0100180 ${HEADER_DIR}/internal/catch_wildcard_pattern.h
Martin Hořeňovský531d2672017-01-16 19:56:57 +0100181 ${HEADER_DIR}/internal/catch_windows_h_proxy.h
Phil Nashca7021a2017-09-07 12:58:44 +0100182 ${HEADER_DIR}/internal/catch_xmlwriter.h
Martin Hořeňovskýe6ef60a2017-01-15 22:07:36 +0100183 )
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200184set(IMPL_SOURCES
Martin Hořeňovskýedbe1222017-07-19 10:01:06 +0200185 ${HEADER_DIR}/internal/catch_approx.cpp
Phil Nashf247ce52017-08-08 17:53:01 +0100186 ${HEADER_DIR}/internal/catch_assertionhandler.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200187 ${HEADER_DIR}/internal/catch_assertionresult.cpp
Phil Nasha9b68132017-08-04 19:23:30 +0100188 ${HEADER_DIR}/internal/catch_benchmark.cpp
Phil Nashee9b19e2017-08-09 12:10:14 +0100189 ${HEADER_DIR}/internal/catch_capture_matchers.cpp
Martin Hořeňovský1d3bfa02017-07-10 14:25:38 +0200190 ${HEADER_DIR}/internal/catch_commandline.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200191 ${HEADER_DIR}/internal/catch_common.cpp
Martin Hořeňovský4a1e8982017-07-19 10:13:47 +0200192 ${HEADER_DIR}/internal/catch_config.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200193 ${HEADER_DIR}/internal/catch_console_colour.cpp
194 ${HEADER_DIR}/internal/catch_context.cpp
Martin Hořeňovský59325762017-08-29 13:51:55 +0200195 ${HEADER_DIR}/internal/catch_debug_console.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200196 ${HEADER_DIR}/internal/catch_debugger.cpp
Phil Nashf247ce52017-08-08 17:53:01 +0100197 ${HEADER_DIR}/internal/catch_decomposer.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200198 ${HEADER_DIR}/internal/catch_errno_guard.cpp
Martin Hořeňovský1d3bfa02017-07-10 14:25:38 +0200199 ${HEADER_DIR}/internal/catch_exception_translator_registry.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200200 ${HEADER_DIR}/internal/catch_fatal_condition.cpp
Martin Hořeňovský9aa96712017-09-07 16:51:33 +0200201 ${HEADER_DIR}/internal/catch_interfaces_capture.cpp
202 ${HEADER_DIR}/internal/catch_interfaces_config.cpp
203 ${HEADER_DIR}/internal/catch_interfaces_exception.cpp
204 ${HEADER_DIR}/internal/catch_interfaces_registry_hub.cpp
205 ${HEADER_DIR}/internal/catch_interfaces_runner.cpp
206 ${HEADER_DIR}/internal/catch_interfaces_testcase.cpp
Martin Hořeňovský1d3bfa02017-07-10 14:25:38 +0200207 ${HEADER_DIR}/internal/catch_list.cpp
Martin Hořeňovský4332b842017-07-12 14:47:36 +0200208 ${HEADER_DIR}/internal/catch_leak_detector.cpp
Martin Hořeňovský87a66b82017-07-20 00:27:28 +0200209 ${HEADER_DIR}/internal/catch_matchers.cpp
Martin Hořeňovský0b1f1b12017-11-10 18:14:42 +0100210 ${HEADER_DIR}/internal/catch_matchers_floating.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200211 ${HEADER_DIR}/internal/catch_matchers_string.cpp
212 ${HEADER_DIR}/internal/catch_message.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200213 ${HEADER_DIR}/internal/catch_registry_hub.cpp
Martin Hořeňovský4a1e8982017-07-19 10:13:47 +0200214 ${HEADER_DIR}/internal/catch_interfaces_reporter.cpp
Martin Hořeňovský0673b9b2017-08-30 15:32:44 +0200215 ${HEADER_DIR}/internal/catch_random_number_generator.cpp
Martin Hořeňovský9aa96712017-09-07 16:51:33 +0200216 ${HEADER_DIR}/internal/catch_reporter_registry.cpp
Martin Hořeňovský8d8f4812017-07-12 16:07:10 +0200217 ${HEADER_DIR}/internal/catch_result_type.cpp
Martin Hořeňovský7ccf11d2017-07-15 16:48:21 +0200218 ${HEADER_DIR}/internal/catch_run_context.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200219 ${HEADER_DIR}/internal/catch_section.cpp
Martin Hořeňovskýd4e796c2017-08-01 17:51:32 +0200220 ${HEADER_DIR}/internal/catch_section_info.cpp
Martin Hořeňovskýe8717422017-08-31 10:31:52 +0200221 ${HEADER_DIR}/internal/catch_session.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200222 ${HEADER_DIR}/internal/catch_startup_exception_registry.cpp
Martin Hořeňovský11295a22017-08-10 11:45:05 +0200223 ${HEADER_DIR}/internal/catch_stream.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200224 ${HEADER_DIR}/internal/catch_stringref.cpp
Martin Hořeňovský1a961752017-07-25 21:57:35 +0200225 ${HEADER_DIR}/internal/catch_string_manip.cpp
Martin Hořeňovský9de729b2017-07-25 22:13:14 +0200226 ${HEADER_DIR}/internal/catch_tag_alias.cpp
Martin Hořeňovský33fd54a2017-07-27 11:55:30 +0200227 ${HEADER_DIR}/internal/catch_tag_alias_autoregistrar.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200228 ${HEADER_DIR}/internal/catch_tag_alias_registry.cpp
229 ${HEADER_DIR}/internal/catch_test_case_info.cpp
Martin Hořeňovskýa75eaa32017-07-25 22:41:35 +0200230 ${HEADER_DIR}/internal/catch_test_case_registry_impl.cpp
Martin Hořeňovský4a1e8982017-07-19 10:13:47 +0200231 ${HEADER_DIR}/internal/catch_test_case_tracker.cpp
Martin Hořeňovskýa75eaa32017-07-25 22:41:35 +0200232 ${HEADER_DIR}/internal/catch_test_registry.cpp
Martin Hořeňovský4a1e8982017-07-19 10:13:47 +0200233 ${HEADER_DIR}/internal/catch_test_spec.cpp
234 ${HEADER_DIR}/internal/catch_test_spec_parser.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200235 ${HEADER_DIR}/internal/catch_timer.cpp
236 ${HEADER_DIR}/internal/catch_tostring.cpp
Martin Hořeňovský4a1e8982017-07-19 10:13:47 +0200237 ${HEADER_DIR}/internal/catch_totals.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200238 ${HEADER_DIR}/internal/catch_version.cpp
Martin Hořeňovský4a1e8982017-07-19 10:13:47 +0200239 ${HEADER_DIR}/internal/catch_wildcard_pattern.cpp
240 ${HEADER_DIR}/internal/catch_xmlwriter.cpp
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200241 )
242set(INTERNAL_FILES ${IMPL_SOURCES} ${INTERNAL_HEADERS})
243CheckFileList(INTERNAL_FILES ${HEADER_DIR}/internal)
Martin Hořeňovskýe6ef60a2017-01-15 22:07:36 +0100244
245# Please keep these ordered alphabetically
246set(REPORTER_HEADERS
Justin Wilsonb753f052017-02-22 04:17:25 -0600247 ${HEADER_DIR}/reporters/catch_reporter_automake.hpp
Phil Nashe1fbbe12017-01-06 16:59:18 +0000248 ${HEADER_DIR}/reporters/catch_reporter_bases.hpp
Martin Hořeňovský4a1e8982017-07-19 10:13:47 +0200249 ${HEADER_DIR}/reporters/catch_reporter_multi.h
Martin Hořeňovskýb0260c62017-02-22 13:28:13 +0100250 ${HEADER_DIR}/reporters/catch_reporter_tap.hpp
Phil Nashe1fbbe12017-01-06 16:59:18 +0000251 ${HEADER_DIR}/reporters/catch_reporter_teamcity.hpp
Phil Nashe1fbbe12017-01-06 16:59:18 +0000252 )
Martin Hořeňovský5f3f19d2017-07-10 11:33:18 +0200253set(REPORTER_SOURCES
254 ${HEADER_DIR}/reporters/catch_reporter_bases.cpp
255 ${HEADER_DIR}/reporters/catch_reporter_compact.cpp
256 ${HEADER_DIR}/reporters/catch_reporter_console.cpp
257 ${HEADER_DIR}/reporters/catch_reporter_junit.cpp
258 ${HEADER_DIR}/reporters/catch_reporter_multi.cpp
259 ${HEADER_DIR}/reporters/catch_reporter_xml.cpp
260 )
261set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES})
262CheckFileList(REPORTER_FILES ${HEADER_DIR}/reporters)
Martin Hořeňovskýe6ef60a2017-01-15 22:07:36 +0100263
264# Specify the headers, too, so CLion recognises them as project files
265set(HEADERS
266 ${TOP_LEVEL_HEADERS}
267 ${EXTERNAL_HEADERS}
268 ${INTERNAL_HEADERS}
269 ${REPORTER_HEADERS}
270 )
271
Phil Nashd5360e82017-01-12 11:54:53 +0000272# Provide some groupings for IDEs
Phil Nash8abe17a2017-01-09 16:27:06 +0000273SOURCE_GROUP("Tests" FILES ${TEST_SOURCES})
Martin Hořeňovskýfc321652017-07-06 22:28:42 +0200274SOURCE_GROUP("Surrogates" FILES ${SURROGATE_SOURCES})
Phil Nash8abe17a2017-01-09 16:27:06 +0000275
Kostace441a92013-08-05 12:40:33 +0200276# configure the executable
Kostace441a92013-08-05 12:40:33 +0200277
Martin Hořeňovský9ceae8f2017-04-28 20:27:10 +0200278# Projects consuming Catch via ExternalProject_Add might want to use install step
279# without building all of our selftests.
280if (NOT NO_SELFTEST)
Martin Hořeňovský5f3f19d2017-07-10 11:33:18 +0200281 add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${SURROGATE_SOURCES} ${HEADERS})
Martin Moenefa9c4202017-11-04 19:19:48 +0100282 target_include_directories(SelfTest PRIVATE ${HEADER_DIR})
Martin Hořeňovský9ceae8f2017-04-28 20:27:10 +0200283
Martin Hořeňovský7a562d32017-11-05 13:11:00 +0100284 if(USE_CPP14)
285 message(STATUS "Enabling C++14")
286 set_property(TARGET SelfTest PROPERTY CXX_STANDARD 14)
287 else()
288 message(STATUS "Enabling C++11")
289 set_property(TARGET SelfTest PROPERTY CXX_STANDARD 11)
290 endif()
291
292 set_property(TARGET SelfTest PROPERTY CXX_STANDARD_REQUIRED ON)
293 set_property(TARGET SelfTest PROPERTY CXX_EXTENSIONS OFF)
294
295
Martin Hořeňovský9ceae8f2017-04-28 20:27:10 +0200296 # Add desired warnings
297 if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
Martin Hořeňovský9aa96712017-09-07 16:51:33 +0200298 target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code )
Martin Hořeňovský9aa96712017-09-07 16:51:33 +0200299 endif()
300 # Clang specific warning go here
301 if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
302 # Actually keep these
303 target_compile_options( SelfTest PRIVATE -Wweak-vtables -Wexit-time-destructors -Wglobal-constructors -Wmissing-noreturn )
Martin Hořeňovský9ceae8f2017-04-28 20:27:10 +0200304 endif()
305 if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
Martin Hořeňovskýc6725122017-10-30 12:14:20 +0100306 target_compile_options( SelfTest PRIVATE /W4 /w44265 /WX /w44061 /w44062 )
Martin Hořeňovský9ceae8f2017-04-28 20:27:10 +0200307 endif()
Martin Hořeňovský7ae96c72017-01-31 17:37:27 +0100308
309
Martin Hořeňovský9ceae8f2017-04-28 20:27:10 +0200310 # configure unit tests via CTest
311 enable_testing()
Martin Hořeňovskýa20b2862017-11-05 12:46:04 +0100312 add_test(NAME RunTests COMMAND $<TARGET_FILE:SelfTest>)
Fraser Hutchison69a3f162013-10-24 02:57:46 +0100313
Martin Hořeňovskýa20b2862017-11-05 12:46:04 +0100314 add_test(NAME ListTests COMMAND $<TARGET_FILE:SelfTest> --list-tests)
Martin Hořeňovský9ceae8f2017-04-28 20:27:10 +0200315 set_tests_properties(ListTests PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ test cases")
Fraser Hutchison69a3f162013-10-24 02:57:46 +0100316
Martin Hořeňovskýa20b2862017-11-05 12:46:04 +0100317 add_test(NAME ListTags COMMAND $<TARGET_FILE:SelfTest> --list-tags)
Martin Hořeňovský9ceae8f2017-04-28 20:27:10 +0200318 set_tests_properties(ListTags PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ tags")
319
Martin Hořeňovskýab5d1762017-09-01 20:28:49 +0200320 # AppVeyor has a Python 2.7 in path, but doesn't have .py files as autorunnable
Martin Hořeňovskýb3a92312017-09-01 19:12:15 +0200321 add_test(NAME ApprovalTests COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/scripts/approvalTests.py $<TARGET_FILE:SelfTest>)
Martin Hořeňovský3a5b9512017-08-31 12:00:35 +0200322 set_tests_properties(ApprovalTests PROPERTIES FAIL_REGULAR_EXPRESSION "Results differed")
Martin Hořeňovskýa20b2862017-11-05 12:46:04 +0100323
324 if (USE_VALGRIND)
325 add_test(NAME ValgrindRunTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest>)
326 add_test(NAME ValgrindListTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest> --list-tests)
327 set_tests_properties(ValgrindListTests PROPERTIES PASS_REGULAR_EXPRESSION "definitely lost: 0 bytes in 0 blocks")
328 add_test(NAME ValgrindListTags COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest> --list-tags)
329 set_tests_properties(ValgrindListTags PROPERTIES PASS_REGULAR_EXPRESSION "definitely lost: 0 bytes in 0 blocks")
330 endif()
331
Martin Hořeňovský9ceae8f2017-04-28 20:27:10 +0200332endif() # !NO_SELFTEST
333
Saad K7dd4f292017-01-31 14:22:45 -0500334
Rian Quinn79ce6932017-03-22 14:19:51 -0600335install(DIRECTORY "single_include/" DESTINATION "include/catch")
Martin Hořeňovskýc7d9f022017-10-12 21:42:09 +0200336
337## Provide some pkg-config integration
338# Don't bother on Windows
339if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
340
341 set(PKGCONFIG_INSTALL_DIR
342 "${CMAKE_INSTALL_PREFIX}/share/pkgconfig"
343 CACHE PATH "Path where catch.pc is installed"
344 )
345
346 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/catch.pc.in ${CMAKE_CURRENT_BINARY_DIR}/catch.pc @ONLY)
347 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/catch.pc DESTINATION ${PKGCONFIG_INSTALL_DIR})
348
349endif()