From 431b80a4151dc60e8e4f2389f176d1f2fb91b011 Mon Sep 17 00:00:00 2001 From: Vijai Kumar S Date: Sun, 2 Jun 2024 21:08:02 +0530 Subject: [PATCH] . --- cmake/lib3mfConfig.cmake | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cmake/lib3mfConfig.cmake b/cmake/lib3mfConfig.cmake index 4f76df7db..ec9f609f6 100644 --- a/cmake/lib3mfConfig.cmake +++ b/cmake/lib3mfConfig.cmake @@ -76,13 +76,19 @@ else() # Define a custom function to handle library copying function(copy_lib3mf_libraries target) if(TARGET ${target}) - if(APPLE) - # On macOS, copy .dylib files, preserving symlinks - add_custom_command(TARGET ${target} POST_BUILD - COMMAND sh -c "cp -P '${lib3mf_LIBRARY_DIR}/lib3mf.dylib'* '$' >/dev/null 2>&1 || true" - COMMENT "Copying all lib3mf library files to target directory on MacOS") + if(APPLE) + # On macOS, copy .dylib files, preserving symlinks only if they don't already exist in the target directory + add_custom_command(TARGET ${target} POST_BUILD + COMMAND sh -c "for file in '${lib3mf_LIBRARY_DIR}/lib3mf.dylib'*; do \ + target_file='$'"