[CMake] Adding a link?
Roger Leigh
rleigh at codelibre.net
Mon Mar 6 08:49:31 EST 2017
On 06/03/2017 12:43, Bernhard Seckinger wrote:
> Hi all,
>
> I've got a project where meanwhile everything works, using cmake, but a tiny
> detail. I've got a frontend which consists of several php files. I copy them
> into a subfolder of share/ with the install command. Now I need a symlink from
> bin/croco to share/croco/main.php that is, after installing everything else "ln
> -s share/croco/main.php bin/croco" should be executed.
>
> I know, that symlinks are not available in some other OSs, but for the time
> being, I only need a solution, that works using linux.
>
> What I found so far is:
>
> add_custom_command(OUTPUT bin/croco
> COMMAND ln -s share/croco/main.php bin/croco
> DEPENDS share/croco/main.php)
>
> But that seems to be ignored by "make install". Can you help me?
bzip2 example (from
https://github.com/ome/ome-cmake-superbuild/blob/master/packages/bzip2/patches/cmake.diff#L163)
# Copy or symlink bunzip2 and bzcat to bzip2
if (WIN32)
install(CODE "configure_file(\"${CMAKE_INSTALL_FULL_BINDIR}/bzip2.exe\"
\"${CMAKE_INSTALL_FULL_BINDIR}/bunzip2.exe\"
COPYONLY)"
COMPONENT "runtime")
install(CODE "configure_file(\"${CMAKE_INSTALL_FULL_BINDIR}/bzip2.exe\"
\"${CMAKE_INSTALL_FULL_BINDIR}/bzcat.exe\"
COPYONLY)"
COMPONENT "runtime")
else()
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E
create_symlink bzip2
\"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/bunzip2\")"
COMPONENT "runtime")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E
create_symlink bzip2
\"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/bzcat\")"
COMPONENT "runtime")
endif()
Hope that's useful as an example,
Roger
More information about the CMake
mailing list