Skip to content

Commit a5b697d

Browse files
committed
CMake Symlink test files
1 parent 7709937 commit a5b697d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cmake/OpenSimMacros.cmake

+9-3
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,15 @@ function(OpenSimAddTests)
390390

391391
# Copy data files to build directory.
392392
foreach(data_file ${OSIMADDTESTS_DATAFILES})
393-
# This command re-copies the data files if they are modified;
394-
# custom commands don't do this.
395-
file(COPY "${data_file}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
393+
# This command symlinks the data files
394+
# from the source directories into the running directory.
395+
# This preserves changes to source files.
396+
get_filename_component(FILENAME ${data_file} NAME)
397+
add_custom_command(
398+
TARGET ${TEST_NAME} POST_BUILD
399+
COMMAND ${CMAKE_COMMAND} -E create_symlink
400+
"${data_file}"
401+
"${CMAKE_CURRENT_BINARY_DIR}/${FILENAME}")
396402
endforeach()
397403

398404
#if(UNIX)

0 commit comments

Comments
 (0)