blob: d906fb7c871aaa263adf7e6ff1dfaccc32eeed6d [file] [log] [blame]
Kostace441a92013-08-05 12:40:33 +02001cmake_minimum_required(VERSION 2.8)
2
Phil Nash0bcae642017-01-09 17:32:57 +00003project(CatchSelfTest)
Kostace441a92013-08-05 12:40:33 +02004
Phil Nash8abe17a2017-01-09 16:27:06 +00005set_property(GLOBAL PROPERTY USE_FOLDERS ON)
6
Kostace441a92013-08-05 12:40:33 +02007# define some folders
Phil Nashc8fefc42017-01-06 16:19:20 +00008set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR})
Kostace441a92013-08-05 12:40:33 +02009set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest)
Phil Nashe1fbbe12017-01-06 16:59:18 +000010set(HEADER_DIR ${CATCH_DIR}/include)
11
Andy Sawyer13cbdf72014-09-04 00:32:05 +010012if(USE_CPP11)
Phil Nash30cebd62016-11-09 22:55:32 +000013 ## 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}")
Andy Sawyer13cbdf72014-09-04 00:32:05 +010016endif()
Kostace441a92013-08-05 12:40:33 +020017
18# define the sources of the self test
Phil Nash8abe17a2017-01-09 16:27:06 +000019set(TEST_SOURCES
Phil Nash30cebd62016-11-09 22:55:32 +000020 ${SELF_TEST_DIR}/ApproxTests.cpp
21 ${SELF_TEST_DIR}/BDDTests.cpp
22 ${SELF_TEST_DIR}/ClassTests.cpp
23 ${SELF_TEST_DIR}/ConditionTests.cpp
24 ${SELF_TEST_DIR}/ExceptionTests.cpp
25 ${SELF_TEST_DIR}/GeneratorTests.cpp
26 ${SELF_TEST_DIR}/MessageTests.cpp
27 ${SELF_TEST_DIR}/MiscTests.cpp
28 ${SELF_TEST_DIR}/PartTrackerTests.cpp
29 ${SELF_TEST_DIR}/TestMain.cpp
30 ${SELF_TEST_DIR}/TrickyTests.cpp
31 ${SELF_TEST_DIR}/VariadicMacrosTests.cpp
32 ${SELF_TEST_DIR}/EnumToString.cpp
33 ${SELF_TEST_DIR}/ToStringPair.cpp
34 ${SELF_TEST_DIR}/ToStringVector.cpp
35 ${SELF_TEST_DIR}/ToStringWhich.cpp
36 ${SELF_TEST_DIR}/ToStringTuple.cpp
37 ${SELF_TEST_DIR}/CmdLineTests.cpp
38 ${SELF_TEST_DIR}/TagAliasTests.cpp
Phil Nash8abe17a2017-01-09 16:27:06 +000039 )
40set(IMPL_SOURCES
Phil Nash30cebd62016-11-09 22:55:32 +000041 ${SELF_TEST_DIR}/SurrogateCpps/catch_common.cpp
42 ${SELF_TEST_DIR}/SurrogateCpps/catch_console_colour.cpp
43 ${SELF_TEST_DIR}/SurrogateCpps/catch_debugger.cpp
44 ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_capture.cpp
45 ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_config.cpp
46 ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_exception.cpp
47 ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_generators.cpp
48 ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_registry_hub.cpp
49 ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_reporter.cpp
50 ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_runner.cpp
51 ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_testcase.cpp
52 ${SELF_TEST_DIR}/SurrogateCpps/catch_message.cpp
53 ${SELF_TEST_DIR}/SurrogateCpps/catch_option.cpp
54 ${SELF_TEST_DIR}/SurrogateCpps/catch_ptr.cpp
55 ${SELF_TEST_DIR}/SurrogateCpps/catch_stream.cpp
56 ${SELF_TEST_DIR}/SurrogateCpps/catch_streambuf.cpp
57 ${SELF_TEST_DIR}/SurrogateCpps/catch_test_spec.cpp
58 ${SELF_TEST_DIR}/SurrogateCpps/catch_xmlwriter.cpp
59 )
Kostace441a92013-08-05 12:40:33 +020060
Phil Nashe1fbbe12017-01-06 16:59:18 +000061# Specify the headers, too, so CLion recognises them as project files
62set(HEADERS
63 ${HEADER_DIR}/catch.hpp
64 ${HEADER_DIR}/catch_session.hpp
65 ${HEADER_DIR}/catch_with_main.hpp
66 ${HEADER_DIR}/internal/catch_approx.hpp
67 ${HEADER_DIR}/internal/catch_assertionresult.h
68 ${HEADER_DIR}/internal/catch_assertionresult.hpp
69 ${HEADER_DIR}/internal/catch_capture.hpp
70 ${HEADER_DIR}/internal/catch_clara.h
71 ${HEADER_DIR}/internal/catch_commandline.hpp
72 ${HEADER_DIR}/internal/catch_common.h
73 ${HEADER_DIR}/internal/catch_common.hpp
74 ${HEADER_DIR}/internal/catch_compiler_capabilities.h
75 ${HEADER_DIR}/internal/catch_config.hpp
76 ${HEADER_DIR}/internal/catch_console_colour.hpp
77 ${HEADER_DIR}/internal/catch_console_colour_impl.hpp
78 ${HEADER_DIR}/internal/catch_context.h
79 ${HEADER_DIR}/internal/catch_context_impl.hpp
80 ${HEADER_DIR}/internal/catch_debugger.h
81 ${HEADER_DIR}/internal/catch_debugger.hpp
82 ${HEADER_DIR}/internal/catch_default_main.hpp
83 ${HEADER_DIR}/internal/catch_evaluate.hpp
84 ${HEADER_DIR}/internal/catch_exception_translator_registry.hpp
85 ${HEADER_DIR}/internal/catch_expression_lhs.hpp
86 ${HEADER_DIR}/internal/catch_fatal_condition.hpp
87 ${HEADER_DIR}/internal/catch_generators.hpp
88 ${HEADER_DIR}/internal/catch_generators_impl.hpp
89 ${HEADER_DIR}/internal/catch_impl.hpp
90 ${HEADER_DIR}/internal/catch_interfaces_capture.h
91 ${HEADER_DIR}/internal/catch_interfaces_config.h
92 ${HEADER_DIR}/internal/catch_interfaces_exception.h
93 ${HEADER_DIR}/internal/catch_interfaces_generators.h
94 ${HEADER_DIR}/internal/catch_interfaces_registry_hub.h
95 ${HEADER_DIR}/internal/catch_interfaces_reporter.h
96 ${HEADER_DIR}/internal/catch_interfaces_runner.h
97 ${HEADER_DIR}/internal/catch_interfaces_tag_alias_registry.h
98 ${HEADER_DIR}/internal/catch_interfaces_testcase.h
99 ${HEADER_DIR}/internal/catch_legacy_reporter_adapter.h
100 ${HEADER_DIR}/internal/catch_legacy_reporter_adapter.hpp
101 ${HEADER_DIR}/internal/catch_list.hpp
102 ${HEADER_DIR}/internal/catch_matchers.hpp
103 ${HEADER_DIR}/internal/catch_message.h
104 ${HEADER_DIR}/internal/catch_message.hpp
105 ${HEADER_DIR}/internal/catch_notimplemented_exception.h
106 ${HEADER_DIR}/internal/catch_notimplemented_exception.hpp
107 ${HEADER_DIR}/internal/catch_objc.hpp
108 ${HEADER_DIR}/internal/catch_objc_arc.hpp
109 ${HEADER_DIR}/internal/catch_option.hpp
110 ${HEADER_DIR}/internal/catch_platform.h
111 ${HEADER_DIR}/internal/catch_ptr.hpp
112 ${HEADER_DIR}/internal/catch_reenable_warnings.h
113 ${HEADER_DIR}/internal/catch_registry_hub.hpp
114 ${HEADER_DIR}/internal/catch_reporter_registrars.hpp
115 ${HEADER_DIR}/internal/catch_reporter_registry.hpp
116 ${HEADER_DIR}/internal/catch_result_builder.h
117 ${HEADER_DIR}/internal/catch_result_builder.hpp
118 ${HEADER_DIR}/internal/catch_result_type.h
119 ${HEADER_DIR}/internal/catch_run_context.hpp
120 ${HEADER_DIR}/internal/catch_section.h
121 ${HEADER_DIR}/internal/catch_section.hpp
122 ${HEADER_DIR}/internal/catch_section_info.h
123 ${HEADER_DIR}/internal/catch_section_info.hpp
124 ${HEADER_DIR}/internal/catch_stream.h
125 ${HEADER_DIR}/internal/catch_stream.hpp
126 ${HEADER_DIR}/internal/catch_streambuf.h
127 ${HEADER_DIR}/internal/catch_suppress_warnings.h
128 ${HEADER_DIR}/internal/catch_tag_alias.h
129 ${HEADER_DIR}/internal/catch_tag_alias_registry.h
130 ${HEADER_DIR}/internal/catch_tag_alias_registry.hpp
131 ${HEADER_DIR}/internal/catch_test_case_info.h
132 ${HEADER_DIR}/internal/catch_test_case_info.hpp
133 ${HEADER_DIR}/internal/catch_test_case_registry_impl.hpp
134 ${HEADER_DIR}/internal/catch_test_case_tracker.hpp
135 ${HEADER_DIR}/internal/catch_test_registry.hpp
136 ${HEADER_DIR}/internal/catch_test_spec.hpp
137 ${HEADER_DIR}/internal/catch_test_spec_parser.hpp
138 ${HEADER_DIR}/internal/catch_text.h
139 ${HEADER_DIR}/internal/catch_timer.h
140 ${HEADER_DIR}/internal/catch_timer.hpp
141 ${HEADER_DIR}/internal/catch_tostring.h
142 ${HEADER_DIR}/internal/catch_tostring.hpp
143 ${HEADER_DIR}/internal/catch_totals.hpp
144 ${HEADER_DIR}/internal/catch_version.h
145 ${HEADER_DIR}/internal/catch_version.hpp
146 ${HEADER_DIR}/internal/catch_wildcard_pattern.hpp
147 ${HEADER_DIR}/internal/catch_xmlwriter.hpp
148 ${HEADER_DIR}/external/clara.h
149 ${HEADER_DIR}/external/tbc_text_format.h
150 ${HEADER_DIR}/reporters/catch_reporter_bases.hpp
151 ${HEADER_DIR}/reporters/catch_reporter_compact.hpp
152 ${HEADER_DIR}/reporters/catch_reporter_console.hpp
153 ${HEADER_DIR}/reporters/catch_reporter_junit.hpp
154 ${HEADER_DIR}/reporters/catch_reporter_multi.hpp
155 ${HEADER_DIR}/reporters/catch_reporter_teamcity.hpp
156 ${HEADER_DIR}/reporters/catch_reporter_xml.hpp
157 )
158
Phil Nash8abe17a2017-01-09 16:27:06 +0000159SOURCE_GROUP("Tests" FILES ${TEST_SOURCES})
160SOURCE_GROUP("Surrogates" FILES ${IMPL_SOURCES})
161
Kostace441a92013-08-05 12:40:33 +0200162# configure the executable
Phil Nashe1fbbe12017-01-06 16:59:18 +0000163include_directories(${HEADER_DIR})
Phil Nash8abe17a2017-01-09 16:27:06 +0000164add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${HEADERS})
Kostace441a92013-08-05 12:40:33 +0200165
Fraser Hutchison69a3f162013-10-24 02:57:46 +0100166# configure unit tests via CTest
Kostace441a92013-08-05 12:40:33 +0200167enable_testing()
Fraser Hutchison69a3f162013-10-24 02:57:46 +0100168add_test(NAME RunTests COMMAND SelfTest)
169
170add_test(NAME ListTests COMMAND SelfTest --list-tests)
171set_tests_properties(ListTests PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ test cases")
172
173add_test(NAME ListTags COMMAND SelfTest --list-tags)
174set_tests_properties(ListTags PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ tags")