2017-02-09 12:08 GMT+01:00 Martin Craig <[email protected]>:

> Hi, got this problem which I've boiled down to a simple test case. My
> source dir contains just one file (realfile) and the installation should
> install this in bin and make a symlink from linkfile to it. This is the
> CMakeLists.txt file:
>
>     cmake_minimum_required(VERSION 2.8.0)
>
>     INSTALL(FILES realfile DESTINATION bin)
>     INSTALL(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E
> create_symlink realfile ${CMAKE_INSTALL_PREFIX}/bin/linkfile)")
>

You could do it in two separate steps and without absolute path:

execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
../../some_relative_path/bin/realfile linkfile) # at this point path
doesn't need to point to the location of existing file
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/linkfile DESTINATION
some_relative_path COMPONENT libraries)

Not certain which CPack package generator you're using but in case of
CPackRPM there is quite some automated handling of symlink paths (even
support for symlinks in relocatable rpm packages).

In this file are some examples of using symlinks in combination with
CPackRPM (never checked how they behave with other CPack package generators
though...):

https://cmake.org/gitweb?p=cmake.git;a=blob;f=Tests/CPackComponentsForAll/CMakeLists.txt;h=344084317166ff4f62850ed77807af2647db6d6a;hb=HEAD

Side note - during packaging CPACK_PACKAGING_INSTALL_PREFIX is used instead
of CMAKE_INSTALL_PREFIX.

Regards,
Domen
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to