I am using FILE(INSTALL files) but some of the files are symbolic links. Can I tell CMake to dereference the symbolic link instead of creating a symbolic link on destination?
Asked
Active
Viewed 5,068 times
11
-
1Please, if you think the answer is correct mark is as answer, it worked for me and I guess I would find it faster if it would be marked as correct answer – kreuzerkrieg Feb 27 '19 at 19:11
1 Answers
21
You can dereference the files programmatically before passing them to install(FILES ...)
:
set (_resolvedFiles "")
foreach (_file ${_files})
get_filename_component(_resolvedFile "${_file}" REALPATH)
list (APPEND _resolvedFiles "${_resolvedFile}")
endforeach()
install(FILES ${_resolvedFiles} DESTINATION ${_dest})

sakra
- 62,199
- 16
- 168
- 151
-
This is the right answer among many others that say this is not possible. Thx – Menno Deij - van Rijswijk Apr 17 '18 at 12:06
-
This is only possible if the files already exist at configure time. It does not work for installing files symlinked by an ExternalProject dependency (because they are not built at configure time). – John Freeman Mar 20 '22 at 22:39