Skip to content

Commit

Permalink
Add TEST_SRCS property and swift_add_test_srcs_target macro [BUILD-65…
Browse files Browse the repository at this point in the history
…7] (#151)

* Add TEST_SRCS global property [BUILD-657]

* Add swift_add_test_srcs_target macro
  • Loading branch information
krisukox authored Apr 24, 2023
1 parent d165dd7 commit b5f4e04
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions TestTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,27 @@ function(swift_add_test target)
add_dependencies(build-post-build-tests ${target})
add_dependencies(post-build-${target} build-post-build-tests)
endif()

foreach(src ${x_SRCS})
get_filename_component(absolute_src ${src} ABSOLUTE)
if(${absolute_src} MATCHES "${CMAKE_BINARY_DIR}.*")
continue()
endif()
string(REPLACE ${PROJECT_SOURCE_DIR}/ "" relative_src ${absolute_src})

set_property(GLOBAL
APPEND_STRING
PROPERTY TEST_SRCS "\\n${relative_src}")
endforeach()

endfunction()

macro(swift_add_test_srcs_target)
get_property(test_srcs GLOBAL PROPERTY TEST_SRCS)

string (REPLACE ";" "\\n" test_srcs_str "${test_srcs}")

add_custom_target(test_srcs
COMMAND echo "'${test_srcs_str}'" | tail -n +2 | sort > cmake_test_srcs.txt
)
endmacro()

0 comments on commit b5f4e04

Please sign in to comment.