Re: [CMake] Using CMAKE_INSTALL_PREFIX in custom install command fails with CPack

2017-02-09 Thread Domen Vrankar
2017-02-09 12:08 GMT+01:00 Martin Craig :

> 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

[CMake] Using CMAKE_INSTALL_PREFIX in custom install command fails with CPack

2017-02-09 Thread Martin Craig
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)")

include(CPack)

This works fine with make install provided I can write to 
${CMAKE_INSTALL_PREFIX}, however with make package, CMAKE_INSTALL_PREFIX is not 
apparently set to the temporary install location that CPack is using, and so it 
fails.

Any idea how I can work around this, or a better way of doing this task? I need 
it for creating symlinks, and also another install command which generates an 
index file in the install directory.

Thanks for any help,
Martin.

-- 

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