Skip to content

Commit b5f4e04

Browse files
authored
Add TEST_SRCS property and swift_add_test_srcs_target macro [BUILD-657] (#151)
* Add TEST_SRCS global property [BUILD-657] * Add swift_add_test_srcs_target macro
1 parent d165dd7 commit b5f4e04

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

TestTargets.cmake

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,27 @@ function(swift_add_test target)
397397
add_dependencies(build-post-build-tests ${target})
398398
add_dependencies(post-build-${target} build-post-build-tests)
399399
endif()
400+
401+
foreach(src ${x_SRCS})
402+
get_filename_component(absolute_src ${src} ABSOLUTE)
403+
if(${absolute_src} MATCHES "${CMAKE_BINARY_DIR}.*")
404+
continue()
405+
endif()
406+
string(REPLACE ${PROJECT_SOURCE_DIR}/ "" relative_src ${absolute_src})
407+
408+
set_property(GLOBAL
409+
APPEND_STRING
410+
PROPERTY TEST_SRCS "\\n${relative_src}")
411+
endforeach()
412+
400413
endfunction()
414+
415+
macro(swift_add_test_srcs_target)
416+
get_property(test_srcs GLOBAL PROPERTY TEST_SRCS)
417+
418+
string (REPLACE ";" "\\n" test_srcs_str "${test_srcs}")
419+
420+
add_custom_target(test_srcs
421+
COMMAND echo "'${test_srcs_str}'" | tail -n +2 | sort > cmake_test_srcs.txt
422+
)
423+
endmacro()

0 commit comments

Comments
 (0)