diff --git a/cmake/OpenSimMacros.cmake b/cmake/OpenSimMacros.cmake index e1b9e537e9..6b935f9c4a 100644 --- a/cmake/OpenSimMacros.cmake +++ b/cmake/OpenSimMacros.cmake @@ -390,9 +390,15 @@ function(OpenSimAddTests) # Copy data files to build directory. foreach(data_file ${OSIMADDTESTS_DATAFILES}) - # This command re-copies the data files if they are modified; - # custom commands don't do this. - file(COPY "${data_file}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") + # This command symlinks the data files + # from the source directories into the running directory. + # This preserves changes to source files. + get_filename_component(FILENAME ${data_file} NAME) + add_custom_command( + TARGET ${TEST_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E create_symlink + "${data_file}" + "${CMAKE_CURRENT_BINARY_DIR}/${FILENAME}") endforeach() #if(UNIX)