Re: [CMake] Setting target destination and rpath per generator

2011-02-15 Thread Daryl N
Thank you!  I did not know about $ORIGIN but that is indeed exactly what I need.





From: Alexander Neundorf 
To: cmake@cmake.org
Cc: Daryl N 
Sent: Tue, February 15, 2011 3:45:25 PM
Subject: Re: [CMake] Setting target destination and rpath per generator

On Tuesday 15 February 2011, Daryl N wrote:
> 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/.
>
> 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( 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( DESTINATION ${BIN_PATH})
> install( 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.

Are you sure "." does what you want ? I can remember I tried it to, and didn't 
what I needed, but I can't remember the details.

Do you know about $ORIGIN for the RPATH ? This means the location of the 
containing ELF file.

Alex



  ___
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Setting target destination and rpath per generator

2011-02-15 Thread Daryl N
Sorry, don't know how to reply inline with this editor.  Yes, 
cpack_config.cmake 
is my CPACK_PROJECT_CONFIG_FILE.  For rpath, here is what I have in the cpack 
config file:

if (${CPACK_GENERATOR} STREQUAL "TGZ")
set(CPACK_SET_DESTDIR OFF)
set(CMAKE_INSTALL_RPATH ".")
set_target_properties(npManager
  PROPERTIES INSTALL_RPATH ".")
elseif (${CPACK_GENERATOR} STREQUAL "DEB")
set(CPACK_SET_DESTDIR ON)
set(CMAKE_INSTALL_RPATH "/usr/local/")
set_target_properties(npManager
  PROPERTIES INSTALL_RPATH "/usr/local/")
endif ()


CMAKE_INSTALL_RPATH was initially set to /user/local/ in my main 
CMakeLists.txt file and it stays that way in TGZ even with the sets above.  For 
the TGZ file I want to be able to unpack it and then just run it locally.  If I 
use the bin/lib folder structure in the TGZ, then I would need to set rpath to 
"../lib" for them to be found.  And then that would be part of the rpath for 
the 
DEB package too.  Sounds like 2 build cycles may be needed.

Daryl

From: Eric Noulard 

To: Daryl N 
Cc: cmake@cmake.org
Sent: Tue, February 15, 2011 4:00:17 AM
Subject: Re: [CMake] Setting target destination and rpath per generator

2011/2/15 Daryl N :
> 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/.
>
> 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( 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( DESTINATION ${BIN_PATH})
> install( 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
> .

I suppose cpack_config.cmake is your CPACK_PROJECT_CONFIG_FILE.
As far as I know you cannot change install rules on "CPack generator basis".

install rules belongs to CMakeLists.txt and they are evaluated at CMake-time
(not CPack-time).

cpack_config.cmake is evaluated at CPack-time, i.e. when CPack runs.
You can do CPack-generator specific actions in this file.
(like setting CPACK_SET_DESTDIR OFF or ON or changing
CPACK_PACKAGING_INSTALL_PREFIX etc...)

I did not tried playing with rpath but may be you can

if(CPACK_GENERATOR MATCHES "TGZ")
  set(CMAKE_INSTALL_RPATH ".")
  set(CPACK_SET_DESTDIR  "OFF")
endif(CPACK_GENERATOR MATCHES "TGZ")

if(CPACK_GENERATOR MATCHES "DEB")
  set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local/")
endif(CPACK_GENERATOR MATCHES "DEB")

> 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/.  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 don't know whether if CMAKE_INSTALL_RPATH can be changed at CPack time
(as I suggested in my previous example) you'll have to try and
may be verify in the CMake source code in order to check  when it is handled.
Whatever the current status,
I don't see why it couldn't be handled at CPack time
(but I may be missing something).

>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.

2 build cycles will definitely work.

However if you gives us more information on what's inside your
"cpack_config.cmake"
what works what does not work with it, may be we can see if it it can
be done in a single build.

I think the main issue is the fact that as far

[CMake] Setting target destination and rpath per generator

2011-02-14 Thread Daryl N
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/.

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( 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( DESTINATION ${BIN_PATH})
install( 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/ 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/.  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/".  The downside is that if a platform has both a DEB package installed 
and the TGZ extracted, if you run the /usr/local/ 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


  ___
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake