@@ -30,102 +30,6 @@ macro(add_unittest _name _source)
30
30
add_dependencies (unit_tests ${_target} )
31
31
endmacro ()
32
32
33
- # This function adds a non compile test. To this end it
34
- # - Adds a target to process the file at `src`, and converts begin/end macros
35
- # to `#if defined` in an extra file
36
- # - Adds an executable target for that source file, excludes it from the default build
37
- # Set a preprocessor define to enable ONE critical section.
38
- # - Adds a test job to ctest which invokes CMake to build this executable target.
39
- # The test is set to fail if the build succeeds, i.e. testing if something doesn't compile
40
- # - Adds a closure test where it's supposed to actually compile if all of the
41
- # critical sections are removed
42
- function (add_non_compile_test name src)
43
- # Don't add anything if the corresponding flag is not set
44
- if (NOT ACTS_BUILD_NONCOMPILE_TESTS)
45
- return ()
46
- endif ()
47
-
48
- # Figure out where to put the output file
49
- cmake_path(ABSOLUTE_PATH src)
50
- get_filename_component (_filename ${src} NAME )
51
- set (_processed_source "${CMAKE_CURRENT_BINARY_DIR} /${_filename} " )
52
-
53
- # Add a build step to generate the source file by invoking a CMake script
54
- add_custom_command (
55
- OUTPUT ${_processed_source}
56
- DEPENDS ${src}
57
- COMMAND
58
- "${CMAKE_COMMAND} " -DINPUT_FILE=${src}
59
- -DOUTPUT_FILE=${_processed_source} -P
60
- ${CMAKE_SOURCE_DIR} /cmake/ActsGenerateNonCompileTest.cmake
61
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
62
- )
63
- add_custom_target ("${name} _generated_source" DEPENDS ${_processed_source} )
64
-
65
- # Create the executable target, add the generated source code as a
66
- # dependencies, so that it's generated when required.
67
- set (test "ActsNonCompileTest${name} Closure" )
68
- set (target "${test} _Executable" )
69
- add_executable (${target} ${_processed_source} )
70
- target_link_libraries (${target} PUBLIC ActsCore ActsTestsCommonHelpers)
71
- add_dependencies (${target} "${name} _generated_source" )
72
-
73
- # Don't build this target by default
74
- set_target_properties (
75
- ${target}
76
- PROPERTIES EXCLUDE_FROM_ALL ON EXCLUDE_FROM_DEFAULT_BUILD ON
77
- )
78
-
79
- # Add the test that calls into CMake to build the target. This one we expect to succeed
80
- add_test (
81
- NAME ${test}
82
- COMMAND
83
- ${CMAKE_COMMAND} --build . --target ${target} --config
84
- $<CONFIGURATION >
85
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
86
- )
87
-
88
- # Loop over critical section markers and add one pair of executable targets and
89
- # and test jobs. The test jobs are flipped, so success is failure.
90
- file (READ ${src} content )
91
- string (
92
- REGEX MATCHALL
93
- "ACTS_DOES_NOT_COMPILE_BEGIN\\ (([A-Za-z0-9]+)\\ )"
94
- matches
95
- ${content}
96
- )
97
- foreach (match ${matches} )
98
- string (
99
- REGEX REPLACE
100
- "ACTS_DOES_NOT_COMPILE_BEGIN\\ (([A-Za-z0-9]+)\\ )"
101
- "\\ 1"
102
- match
103
- ${match}
104
- )
105
-
106
- set (test "ActsNonCompileTest${name}${match} " )
107
- set (target "${test} _Executable" )
108
- add_executable (${target} ${_processed_source} )
109
- target_link_libraries (${target} PUBLIC ActsCore ActsTestsCommonHelpers)
110
- target_compile_definitions (${target} PRIVATE "-D${match} " )
111
- add_dependencies (${target} "${name} _generated_source" )
112
-
113
- set_target_properties (
114
- ${target}
115
- PROPERTIES EXCLUDE_FROM_ALL ON EXCLUDE_FROM_DEFAULT_BUILD ON
116
- )
117
-
118
- add_test (
119
- NAME ${test}
120
- COMMAND
121
- ${CMAKE_COMMAND} --build . --target ${target} --config
122
- $<CONFIGURATION >
123
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
124
- )
125
- set_tests_properties (${test} PROPERTIES WILL_FAIL ON )
126
- endforeach ()
127
- endfunction ()
128
-
129
33
add_subdirectory (Core)
130
34
add_subdirectory_if(Examples ACTS_BUILD_EXAMPLES AND ACTS_BUILD_EXAMPLES_UNITTESTS)
131
35
add_subdirectory_if(Benchmarks ACTS_BUILD_BENCHMARKS)
0 commit comments