[CMake] Setting target destination and rpath per generator

Daryl N darylhouse2004 at yahoo.com
Mon Feb 14 21:23:41 EST 2011


Hi,

I have a question on the use of CPack.  I have CMake setup to generate binaries 
and shared libraries.  Up until now I have only created a TGZ with rpath set to 
".".  This has worked nicely, but now I would like to create a Debian package 
for proper installation.  I have added DEB to CPACK_GENERATOR and I've created 
my own cpack_config.cmake file.  My goal is:

1. Run cmake/make package once and create the tar.gz file with all exe/libs in 
the root folder of the tar.gz file with rpath set to ".".
2. Create new .deb package with exes in /usr/local/bin and libs in 
/usr/local/lib.  Alternatively, since files are private, all could be put in 
/usr/local/<some folder>.

I've attempted this by creating my own cpack_config.cmake file to try to 
override some settings per generator.  Some observations:

1. I've been unable to set the install(<target> DESTINATION) path per generator 
in my cpack_config.cmake file.  Whatever the variable is set to when the 
install(...) is processed in the CMakeLists.txt file is what is used for all 
generators.  Just want to confirm changing this isn't an option per generator.

The above has prevented me from having my install lines like:
    install(<target> DESTINATION ${BIN_PATH})
    install(<target> DESTINATION ${LIB_PATH})
and then setting BIN_PATH to bin and LIB_PATH to lib for DEB, but setting them 
to "." for TGZ, since I can't change the variable in cpack_config.cmake.

My current solution is to set CMAKE_INSTALL_PREFIX (before first project tag) to 
/usr/local/<some folder> and set BIN_PATH and LIB_PATH to ".".  I also have to 
set CPACK_SET_DESTDIR to OFF in the cpack config to have the TGZ just use ".".  
Am I missing a better way?

2. I would also like to set the rpath per generator.  So the targets in the TGZ 
only look in "." while the DEB installed targets only look in /usr/local/<some 
folder>.  But I haven't been able to update the rpath per generator in 
cpack_config.cmake.  I've tried both setting CMAKE_INSTALL_RPATH and using 
set_target_properties(... PROPERTIES INSTALL_RPATH).  Again, I'm assuming this 
can't be changed at CPack time.

I've worked around this be setting CMAKE_INSTALL_RPATH to ".;/usr/local/<some 
folder>".  The downside is that if a platform has both a DEB package installed 
and the TGZ extracted, if you run the /usr/local/<some folder> exe (assuming in 
path) from the folder where the tar.gz is extracted, then it may pick up the 
wrong libraries. I'm currently not versioning my libraries and perhaps that's 
the right way to handle it.  But I was hoping to simply set the rpath per 
generator.  Do I need to run cpack separately changing the variables before 
hand?  I suppose that would mean 2 builds cycles also, once for each generator.

Thanks for any help,
Daryl


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110214/216fe616/attachment.htm>


More information about the CMake mailing list