Skip to content

Commit cc9ab19

Browse files
committed
Update target linking
1 parent 442d8da commit cc9ab19

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

cmake/OpenSimMacros.cmake

+19-12
Original file line numberDiff line numberDiff line change
@@ -386,20 +386,27 @@ function(OpenSimAddTests)
386386
set_target_properties(${TEST_NAME} PROPERTIES
387387
FOLDER "Tests"
388388
)
389+
# Link data files to build directory.
390+
foreach(data_file ${OSIMADDTESTS_DATAFILES})
391+
# This command symlinks the data files
392+
# from the source directories into the running directory.
393+
# This preserves changes to source files.
394+
get_filename_component(FILENAME ${data_file} NAME)
395+
set(link_path "${CMAKE_CURRENT_BINARY_DIR}/${FILENAME}")
396+
if(NOT EXISTS "${link_path}")
397+
add_custom_command(
398+
TARGET ${TEST_NAME} POST_BUILD
399+
COMMAND ${CMAKE_COMMAND} -E create_symlink
400+
"${data_file}"
401+
"${link_path}"
402+
COMMENT "Creating symlink: ${data_file} -> ${link_path}"
403+
)
404+
else()
405+
message(STATUS "Skipping ${data_file}, it already exists in the build directory.")
406+
endif()
407+
endforeach()
389408
endforeach()
390409

391-
# Copy data files to build directory.
392-
foreach(data_file ${OSIMADDTESTS_DATAFILES})
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-
$<TARGET_FILE_DIR:${TEST_NAME}>/${FILENAME})
402-
endforeach()
403410

404411
#if(UNIX)
405412
# add_definitions(-fprofile-arcs -ftest-coverage)

0 commit comments

Comments
 (0)