1
- # - Internal Use file for Geant4
2
- # This file is designed for inclusion by the UseGeant4.cmake file, but
3
- # only in the build tree. It contains functions and macros that are only
4
- # intended to help in building the Geant4 tests.
5
- #
6
- # IT SHOULD NOT BE INSTALLED!
7
-
8
1
#-----------------------------------------------------------------------
9
2
# Special internal functions for building tests.
10
3
#-----------------------------------------------------------------------
23
16
# [LABELS label1 label2 ...])
24
17
#
25
18
function (geant4_add_test test )
26
- if (NOT CMAKE_PROJECT_NAME STREQUAL Geant4)
27
- message (WARNING "geant4_add_test is only for internal Geant4 usage, test '${test} ' is disabled" )
28
- return ()
29
- endif ()
30
-
31
19
cmake_parse_arguments (ARG
32
20
"DEBUG"
33
21
"TIMEOUT;BUILD;OUTPUT;ERROR;SOURCE_DIR;BINARY_DIR;PROJECT;PASSREGEX;FAILREGEX;WORKING_DIRECTORY"
@@ -38,19 +26,31 @@ function(geant4_add_test test)
38
26
set (_cfg $<CONFIGURATION >/)
39
27
endif ()
40
28
29
+ # ARG_BUILD is treated as "zero or one"
30
+ # zero arg: build everything
31
+ # one arg: just that target
32
+ if (ARG_BUILD OR "BUILD" IN_LIST ARG_KEYWORDS_MISSING_VALUES)
33
+ set (_is_build_test TRUE )
34
+ endif ()
35
+
41
36
# COMMAND AND BUILD: split test
42
37
# - In this case, we have to create a -build and a -run test with the latter depending on the former
43
38
# NOT COMMAND AND BUILD: pure build
44
39
# COMMAND AND NOT BUILD: pure test
45
- if (ARG_COMMAND AND ARG_BUILD )
40
+ if (ARG_COMMAND AND _is_build_test )
46
41
set (_is_split_test TRUE )
47
42
endif ()
48
43
44
+ # Supplying a PROJECT argument is now a deprecation warning and will be removed
45
+ if (ARG_PROJECT)
46
+ message (WARNING "Test '${test} ' uses the deprecated 'PROJECT' argument to 'geant4_add_test'. This argument is obsolete" )
47
+ endif ()
48
+
49
49
#- Handle COMMAND argument
50
50
list (LENGTH ARG_COMMAND _len)
51
51
if (_len LESS 1)
52
- if (NOT ARG_BUILD )
53
- message (FATAL_ERROR "GEANT4_ADD_TEST: command is mandatory (without build) " )
52
+ if (NOT _is_build_test )
53
+ message (FATAL_ERROR "geant4_add_test: COMMAND argument is mandatory when BUILD argument is not supplied " )
54
54
endif ()
55
55
else ()
56
56
list (GET ARG_COMMAND 0 _prg)
@@ -125,20 +125,13 @@ function(geant4_add_test test)
125
125
set (_command ${_command} -P ${_driver} )
126
126
127
127
#- Now we can actually add the test
128
- if (ARG_BUILD )
128
+ if (_is_build_test )
129
129
if (NOT ARG_SOURCE_DIR)
130
130
set (ARG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
131
131
endif ()
132
132
if (NOT ARG_BINARY_DIR )
133
133
set (ARG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
134
134
endif ()
135
- if (NOT ARG_PROJECT)
136
- if (NOT PROJECT_NAME STREQUAL "Geant4" )
137
- set (ARG_PROJECT ${PROJECT_NAME} )
138
- else ()
139
- set (ARG_PROJECT ${ARG_BUILD} )
140
- endif ()
141
- endif ()
142
135
143
136
set (__build_test_name "${test} " )
144
137
set (__run_test_name "" )
@@ -148,15 +141,18 @@ function(geant4_add_test test)
148
141
set (__run_test_name "${test} " )
149
142
endif ()
150
143
144
+ if (ARG_BUILD)
145
+ set (__build_argument --build -target ${ARG_BUILD} )
146
+ endif ()
147
+
151
148
# Build part of the test
152
149
# Again, note that we scope Geant4_DIR to Geant4_BINARY_DIR so we don't accidentally pickup
153
150
# local or higher scopes
154
151
add_test (NAME ${__build_test_name} COMMAND ${CMAKE_CTEST_COMMAND}
155
152
--build -and -test ${ARG_SOURCE_DIR} ${ARG_BINARY_DIR}
156
153
--build -generator ${CMAKE_GENERATOR}
157
154
--build -makeprogram ${CMAKE_MAKE_PROGRAM}
158
- --build -target ${ARG_BUILD}
159
- --build -project ${ARG_PROJECT}
155
+ ${__build_argument}
160
156
--build -config $<CONFIGURATION >
161
157
--build -noclean
162
158
--build -options
@@ -175,9 +171,11 @@ function(geant4_add_test test)
175
171
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
176
172
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
177
173
-DCMAKE_CXX_FLAGS_FULLRELWITHDEBINFO=${CMAKE_CXX_FLAGS_FULLRELWITHDEBINFO}
174
+ -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
175
+ -DCMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS}
176
+ -DCMAKE_STATIC_LINKER_FLAGS=${CMAKE_STATIC_LINKER_FLAGS}
178
177
-DCMAKE_DISABLE_FIND_PACKAGE_ROOT=$<BOOL :${CMAKE_DISABLE_FIND_PACKAGE_ROOT} >
179
178
)
180
- set_property (TEST ${__build_test_name} PROPERTY ENVIRONMENT Geant4_DIR=${Geant4_BINARY_DIR} )
181
179
182
180
# Build part of the test should have additional regex, and *must* have same labels
183
181
if (ARG_FAILREGEX)
0 commit comments