Wednesday, October 5, 2022

[SOLVED] Symbolic links CMake

Issue

I want to rename certain executables in CMakeLists.txt but also want symbolic links from the older names to new files for backward compatibility. How can this be accomplished on systems that support symbolic links?

Also what are the alternatives for system that does not support symbolic links?


Solution

You can create a custom target and use CMake to create symlinks

ADD_CUSTOM_TARGET(link_target ALL
                  COMMAND ${CMAKE_COMMAND} -E create_symlink ${target} ${link})

This will only work on systems that support symlinks, see the documentation.

Before CMake v3.14, this did not work on Windows. In v3.13, support for Windows was added.



Answered By - Emil
Answer Checked By - Clifford M. (WPSolving Volunteer)