@@ -13,28 +13,8 @@ find_package(Python3 COMPONENTS Interpreter)
1313
1414findandcheckllvmsymbolizer()
1515
16- # Set executable prefix based on platform
17- if (WIN32 )
18- set (EXEC_PREFIX "" )
19- else ()
20- set (EXEC_PREFIX "./" )
21- endif ()
22-
23- set (CHECK_COMMAND_GLOBAL "" CACHE INTERNAL "Accumulated check commands" FORCE)
24- set (CHECK_DEPENDS_GLOBAL "" CACHE INTERNAL "Accumulated check depends" FORCE)
25- set (CHECK_EXECUTABLE_PATHS_GLOBAL "" CACHE INTERNAL "Accumulated check executable paths" FORCE)
26-
27- # Global collections for unit tests
28- set (UNIT_CHECK_COMMAND_GLOBAL "" CACHE INTERNAL "Accumulated unit check commands" FORCE)
29- set (UNIT_CHECK_DEPENDS_GLOBAL "" CACHE INTERNAL "Accumulated unit check depends" FORCE)
30-
31- # Global collections for integration tests
32- set (INTEGRATION_CHECK_COMMAND_GLOBAL "" CACHE INTERNAL "Accumulated integration check commands"
33- FORCE
34- )
35- set (INTEGRATION_CHECK_DEPENDS_GLOBAL "" CACHE INTERNAL "Accumulated integration check depends"
36- FORCE
37- )
16+ set (CHECK_DEPENDS_GLOBAL "" CACHE INTERNAL "Accumulated global dependencies for test name validation" FORCE)
17+ set (CHECK_EXECUTABLE_PATHS_GLOBAL "" CACHE INTERNAL "Accumulated global check executable paths" FORCE)
3818
3919# Builds the test environment list with optional code coverage support
4020# ~~~
@@ -98,86 +78,6 @@ function(_create_test_name_validation_target_internal)
9878 endif () # Python3_FOUND
9979endfunction () # _create_test_name_validation_target_internal
10080
101- # Generic internal function to append tests to check targets
102- function (_append_test_to_check_target_internal TARGET WORKING_DIR TEST_TYPE STATUS_MESSAGE)
103- if (STATUS_MESSAGE)
104- message (STATUS "${STATUS_MESSAGE} : ${TARGET} in working directory: ${WORKING_DIR} " )
105- endif ()
106-
107- if ("${TEST_TYPE} " STREQUAL "UNIT" )
108- set (COMMAND_VAR "UNIT_CHECK_COMMAND_GLOBAL" )
109- set (DEPENDS_VAR "UNIT_CHECK_DEPENDS_GLOBAL" )
110- set (CACHE_DESC "Accumulated unit check targets" )
111- elseif ("${TEST_TYPE} " STREQUAL "INTEGRATION" )
112- set (COMMAND_VAR "INTEGRATION_CHECK_COMMAND_GLOBAL" )
113- set (DEPENDS_VAR "INTEGRATION_CHECK_DEPENDS_GLOBAL" )
114- set (CACHE_DESC "Accumulated integration check targets" )
115- else ()
116- set (COMMAND_VAR "CHECK_COMMAND_GLOBAL" )
117- set (DEPENDS_VAR "CHECK_DEPENDS_GLOBAL" )
118- set (CACHE_DESC "Accumulated check targets" )
119- endif ()
120-
121- # Build environment list properly
122- _build_test_environment_list_internal(ENVIRONMENT_LIST)
123-
124- set (NEW_COMMAND "" )
125- if ("${${COMMAND_VAR} }" STREQUAL "" )
126- set (NEW_COMMAND ${CMAKE_COMMAND} -E env ${ENVIRONMENT_LIST}
127- ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_BINDIR} /${TARGET}
128- )
129- else ()
130- set (NEW_COMMAND && ${CMAKE_COMMAND} -E env ${ENVIRONMENT_LIST}
131- ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_BINDIR} /${TARGET}
132- )
133- endif ()
134-
135- set (${COMMAND_VAR} ${${COMMAND_VAR} } ${NEW_COMMAND} CACHE INTERNAL "${CACHE_DESC} " FORCE)
136- set (${DEPENDS_VAR} ${${DEPENDS_VAR} } ${TARGET}
137- CACHE INTERNAL "Accumulated ${TEST_TYPE} check depends" FORCE
138- )
139-
140- # Track the binary paths for test name validation
141- set (EXECUTABLE_PATH "${CMAKE_INSTALL_BINDIR} /${TARGET} " )
142- set (CHECK_EXECUTABLE_PATHS_GLOBAL ${CHECK_EXECUTABLE_PATHS_GLOBAL} ${EXECUTABLE_PATH}
143- CACHE INTERNAL "Accumulated check executable paths" FORCE
144- )
145- endfunction () # _append_test_to_check_target_internal
146-
147- # Generic internal function to finalize DIY check targets
148- function (_finalize_check_target_internal TARGET_NAME COMMAND_VAR DEPENDS_VAR)
149- add_custom_target (
150- ${TARGET_NAME}
151- COMMAND ${${COMMAND_VAR} }
152- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
153- DEPENDS ${${DEPENDS_VAR} }
154- VERBATIM
155- COMMENT "Running ${TARGET_NAME} "
156- USES_TERMINAL
157- )
158- message (VERBOSE "Created ${TARGET_NAME} target" )
159- endfunction () # _finalize_check_target_internal
160-
161- # Internal function to finalize the DIY unclassified check-old target
162- function (_finalize_unclassified_check_target_internal)
163- _finalize_check_target_internal("check-old" "CHECK_COMMAND_GLOBAL" "CHECK_DEPENDS_GLOBAL" )
164- endfunction () # _finalize_unclassified_check_target_internal
165-
166- # Internal function to finalize the DIY unit-check-old target
167- function (_finalize_unit_check_target_internal)
168- _finalize_check_target_internal(
169- "unit-check-old" "UNIT_CHECK_COMMAND_GLOBAL" "UNIT_CHECK_DEPENDS_GLOBAL"
170- )
171- endfunction () # _finalize_unit_check_target_internal
172-
173- # Internal function to finalize the DIY integration-check-old target
174- function (_finalize_integration_check_target_internal)
175- _finalize_check_target_internal(
176- "integration-check-old" "INTEGRATION_CHECK_COMMAND_GLOBAL"
177- "INTEGRATION_CHECK_DEPENDS_GLOBAL"
178- )
179- endfunction () # _finalize_integration_check_target_internal
180-
18181enable_testing () # Cmake wont discover or run tests without this line
18282
18383# Internal helper function to create a ctest target
@@ -214,7 +114,7 @@ function(_add_ctest_target_internal TARGET_NAME LABEL VERBOSE COMMENT)
214114 message (VERBOSE "Created ${TARGET_NAME} target" )
215115endfunction () # _add_ctest_target_internal
216116
217- # Internal helper function to create the (new) check targets for running tests via ctest
117+ # Internal helper function to create the check targets for running tests via ctest
218118function (_create_ctest_targets_internal)
219119 # cmake-format: off
220120 # Build test environment once for all ctest targets
@@ -238,12 +138,6 @@ function(finalize_test_targets)
238138
239139 _create_ctest_targets_internal()
240140
241- _finalize_unclassified_check_target_internal()
242- _finalize_unit_check_target_internal()
243- _finalize_integration_check_target_internal()
244-
245- add_dependencies (check-old validate_test_names)
246-
247141 # cmake-format: off
248142 # Create alias test targets without '_ctest' in the name
249143 # Regular targets (without --verbose)
@@ -259,36 +153,37 @@ function(finalize_test_targets)
259153 # cmake-format: on
260154endfunction () # finalize_test_targets
261155
262- # Internal (old) DIY function to add a test target (assumes the test executable is a gtest
263- # executable) Still needed for collecting list of test executables in HIPDNN_TEST_TARGETS and
264- # setting test-type labels. TODO: Deprecate this funcion and remove manual test collection once new
265- # ctest-based method is proven.
266- function (_add_gtest_target_internal APPEND_FUNCTION_SUFFIX TARGET WORKING_DIR)
267- if ("${APPEND_FUNCTION_SUFFIX} " STREQUAL "test" )
268- _append_test_to_check_target_internal(
269- ${TARGET} ${WORKING_DIR} "" "Appending unclassified check target"
270- )
271- elseif ("${APPEND_FUNCTION_SUFFIX} " STREQUAL "unit_test" )
272- _append_test_to_check_target_internal(
273- ${TARGET} ${WORKING_DIR} "UNIT" "Appending unit check target"
274- )
275- _append_test_to_check_target_internal(${TARGET} ${WORKING_DIR} "" "" )
276- elseif ("${APPEND_FUNCTION_SUFFIX} " STREQUAL "integration_test" )
277- _append_test_to_check_target_internal(
278- ${TARGET} ${WORKING_DIR} "INTEGRATION" "Appending integration check target"
279- )
280- _append_test_to_check_target_internal(${TARGET} ${WORKING_DIR} "" "" )
281- else ()
282- message (FATAL_ERROR "Unknown test type suffix: ${APPEND_FUNCTION_SUFFIX} " )
283- endif ()
156+ # ~~~
157+ # Internal helper function to record, configure, and register a ctest test target. Assumes that the
158+ # test target is a gtest executable, setting up:
159+ # - Test name validation tracking (adds to global dependency and executable path lists)
160+ # - RPATH settings for relocatable test executables
161+ # - Installation rules for test binaries
162+ # - CTest registration with appropriate labels (e.g. unit / integration test labels)
163+ # Parameters:
164+ # APPEND_FUNCTION_SUFFIX - Label to apply to the test (e.g., "unit_test", "integration_test", "test")
165+ # TARGET - Name of the test executable target (must already exist)
166+ # WORKING_DIR - Working directory for test execution
167+ # ~~~
168+ function (_add_test_target_internal APPEND_FUNCTION_SUFFIX TARGET WORKING_DIR)
169+ message (STATUS "Appending ${APPEND_FUNCTION_SUFFIX} check target: ${TARGET} in working directory: ${WORKING_DIR} " )
284170
285- set_target_properties (
286- ${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_BINDIR} "
171+ # Track the dependencies for test name validation
172+ set (CHECK_DEPENDS_GLOBAL ${CHECK_DEPENDS_GLOBAL} ${TARGET}
173+ CACHE INTERNAL "Accumulated global dependencies for test name validation" FORCE
174+ )
175+ # Track the binary paths for test name validation
176+ set (CHECK_EXECUTABLE_PATHS_GLOBAL ${CHECK_EXECUTABLE_PATHS_GLOBAL} "${CMAKE_INSTALL_BINDIR} /${TARGET} "
177+ CACHE INTERNAL "Accumulated global check executable paths" FORCE
287178 )
288179
289180 # Track this test target for later use in generating installed CTestTestfile.cmake
290181 set_property (GLOBAL APPEND PROPERTY HIPDNN_TEST_TARGETS ${TARGET} )
291182
183+ set_target_properties (
184+ ${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_BINDIR} "
185+ )
186+
292187 # Make test executables relocatable so they can find libraries when build directory is moved
293188 # Include both the main lib directory and the engine plugin directories
294189 set_target_properties (
@@ -309,17 +204,17 @@ endfunction() # _add_gtest_target_internal
309204
310205# Adds a generic test target
311206function (add_unclassified_test_target TARGET WORKING_DIR)
312- _add_gtest_target_internal (test ${TARGET} ${WORKING_DIR} )
207+ _add_test_target_internal (test ${TARGET} ${WORKING_DIR} )
313208endfunction () # add_unclassified_test_target
314209
315210# Adds a unit test target
316211function (add_unit_test_target TARGET WORKING_DIR)
317- _add_gtest_target_internal (unit_test ${TARGET} ${WORKING_DIR} )
212+ _add_test_target_internal (unit_test ${TARGET} ${WORKING_DIR} )
318213endfunction () # add_unit_test_target
319214
320215# Adds an integration test target
321216function (add_integration_test_target TARGET WORKING_DIR)
322- _add_gtest_target_internal (integration_test ${TARGET} ${WORKING_DIR} )
217+ _add_test_target_internal (integration_test ${TARGET} ${WORKING_DIR} )
323218endfunction () # add_integration_test_target
324219
325220# Install CTest configuration files for direct test execution This should be called once at the end
0 commit comments