[CMake] Setting target destination and rpath per generator

David Cole david.cole at kitware.com
Tue Feb 15 09:42:32 EST 2011


You cannot do "cmake-ish" things in the CPACK_PROJECT_CONFIG_FILE.

Neither install commands nor set_target_properties calls do anything in this
context.



On Tue, Feb 15, 2011 at 9:36 AM, Daryl N <darylhouse2004 at yahoo.com> wrote:

> 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/<some folder>")
>     set_target_properties(npManager
>                           PROPERTIES INSTALL_RPATH "/usr/local/<some
> folder>")
> endif ()
>
> CMAKE_INSTALL_RPATH was initially set to /user/local/<some folder> 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 <eric.noulard at gmail.com>
> *To:* Daryl N <darylhouse2004 at yahoo.com>
> *Cc:* cmake at 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 <darylhouse2004 at yahoo.com>:
> > 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
> > .
>
> 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/<somefolder>")
> 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/<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 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 as I understand your
> need you want
> to put all files (libs, exe) in a single folder for the TGZ and have
> prefix+/lib, prefix+/bin
> in the DEB case?
>
> Changing the prefix is easy but adding (or removing) the extra /lib
> and /bin I don't
> currently know how to do that. Why won't you keep the lib and bin
> suffix in the TGZ case?
>
>
> --
> Erk
> Membre de l'April - « promouvoir et défendre le logiciel libre » -
> http://www.april.org
>
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110215/c8427c43/attachment.htm>


More information about the CMake mailing list