From 97d4c952af203e628b6451ef8899b877f067d5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Matos?= Date: Tue, 21 Jan 2025 17:35:53 +0000 Subject: [PATCH] CMake: Allow using symlinks for installed files. (#19043) * CMake: Allow using symlinks for installed files. --- cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake | 1 + cMake/FreeCadMacros.cmake | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake b/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake index 9ebfaef1ba21..323f4be93606 100644 --- a/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake +++ b/cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake @@ -15,6 +15,7 @@ macro(InitializeFreeCADBuildOptions) option(BUILD_WITH_CONDA "Set ON if you build FreeCAD with conda" OFF) option(BUILD_DYNAMIC_LINK_PYTHON "If OFF extension-modules do not link against python-libraries" ON) option(INSTALL_TO_SITEPACKAGES "If ON the freecad root namespace (python) is installed into python's site-packages" ON) + option(INSTALL_PREFER_SYMLINKS "If ON then fc_copy_sources macro will create symlinks instead of copying files" OFF) option(OCCT_CMAKE_FALLBACK "disable usage of occt-config files" OFF) if (WIN32 OR APPLE) option(FREECAD_USE_QT_FILEDIALOG "Use Qt's file dialog instead of the native one." OFF) diff --git a/cMake/FreeCadMacros.cmake b/cMake/FreeCadMacros.cmake index f5efcdefe665..351909a1b150 100644 --- a/cMake/FreeCadMacros.cmake +++ b/cMake/FreeCadMacros.cmake @@ -9,12 +9,18 @@ MACRO (fc_copy_sources target_name outpath) else() set(fc_details "") endif() + if(INSTALL_PREFER_SYMLINKS) + set(copy_command create_symlink) + else() + set(copy_command copy) + endif() + foreach(it ${ARGN}) get_filename_component(infile ${it} ABSOLUTE) get_filename_component(outfile "${outpath}/${it}" ABSOLUTE) add_file_dependencies("${infile}" "${outfile}") ADD_CUSTOM_COMMAND( - COMMAND "${CMAKE_COMMAND}" -E copy "${infile}" "${outfile}" + COMMAND "${CMAKE_COMMAND}" -E ${copy_command} "${infile}" "${outfile}" OUTPUT "${outfile}" COMMENT "Copying ${infile} to ${outfile}${fc_details}" MAIN_DEPENDENCY "${infile}"