Discussion:
[CMake] Change RPATH at the packaging stage
Vyacheslav Karamov
2012-11-01 19:58:41 UTC
Permalink
Hi All!

Is it possible to change rpath at the packaging stage?
I have CMake based project with CPack directives in its CMake script:

if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")

SET(install_dir "/opt/chatterbox")

SET(CMAKE_SKIP_BUILD_RPATH TRUE)

SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)

SET(CMAKE_INSTALL_RPATH "/usr/local/lib")

SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)

...
endif()
Eric Noulard
2012-11-02 09:06:29 UTC
Permalink
Post by Vyacheslav Karamov
Hi All!
Is it possible to change rpath at the packaging stage?
CPack is using cmake_install.cmake scripts which gets influenced
by CMAKE_INSTALL_RPATH variable and/or INSTALL_RPATH target property.

Did you try to play with that? i.e.

SET(CMAKE_INSTALL_RPATH "/opt/chatterbox")

you may try to set this in a CPACK_PROJECT_CONFIG_FILE
in order to set it to a "CPack-time" specific value.

That said I'm not sure it'll work because I don't know for sure "when exactly"
CMAKE_INSTALL_RPATH is processed, but iit's simple to try.
Post by Vyacheslav Karamov
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
SET(install_dir "/opt/chatterbox")
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH "/usr/local/lib")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
...
endif()
--
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
http://www.cmake.org/mailman/listinfo/cmake
--
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org
Vyacheslav Karamov
2012-11-02 14:40:42 UTC
Permalink
Thank you very much, Eric!
It works!

----------- CMakeLists.txt ------------------

include (FindSubversion)

if (NOT Subversion_FOUND)
message(FATAL_ERROR "Please install subversion command-line client and
add its folder to the system PATH")
endif()

# Update working copy at every non-debug build
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))

add_custom_target(svn_up ALL
# update the working copy
COMMAND ${Subversion_SVN_EXECUTABLE} up ${CMAKE_SOURCE_DIR}
)

endif() # if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))

# Add code which adds svn revision info at every build

Subversion_WC_INFO(${CMAKE_SOURCE_DIR} ${CMAKE_PROJECT_NAME})

set(chatterbox_revision ${${CMAKE_PROJECT_NAME}_WC_REVISION})

# set product version
set (chatterbox_version_major 1)
set (chatterbox_version_minor 0)
set (chatterbox_version_patch 0)
set (chatterbox_version "${chatterbox_version_major},
${chatterbox_version_minor}, ${chatterbox_version_patch},
${chatterbox_revision}")

set(version_h_contents "/**
* Copyright (c) 2008-2012 Transparent Language, Inc. All rights reserved.
*/
#define _VESRION_NUMBER_ ${chatterbox_version}
#define _PRODUCT_NUMBER_ ${chatterbox_version}
#define _VERSION_STRING_ \"${chatterbox_version}\"
#define _PRODUCT_STRING_ \"${chatterbox_version}\"
")

#Write version.h
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/chatterbox/src/version.h"
${version_h_contents})

set (package_version
"${chatterbox_version_major}.${chatterbox_version_minor}.${chatterbox_version_patch}")

add_custom_target(configure_cpack ALL
# generate cpackoptions.cmake at build time so we get the
# most recent revision number
COMMAND ${CMAKE_COMMAND}
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
-Dproj_name=${CMAKE_PROJECT_NAME}
-Drevision=${chatterbox_revision}
-Dpack_version=${package_version}
-P ${CMAKE_SOURCE_DIR}/cmake/Create-cpackoptions.cmake
)

if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
add_dependencies(configure_cpack svn_up)
endif()

set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake/CPackOptions.cmake)

----------- CMakeLists.txt ------------------


---------------Create-cpackoptions.cmake--------------

configure_file(${SOURCE_DIR}/cmake/CPackOptions.cmake.in
${SOURCE_DIR}/cmake/CPackOptions.cmake
@ONLY)

---------------Create-cpackoptions.cmake--------------


--------------------------CPackOptions.cmake.in-----------------------

SET(CMAKE_INSTALL_RPATH "/opt/@proj_name@")
set(CPACK_PACKAGE_VERSION "@pack_version@")
set(CPACK_PACKAGE_FILE_NAME
"@proj_name@-${CPACK_PACKAGE_VERSION}***@revision@-${CPACK_SYSTEM_NAME}")

--------------------------CPackOptions.cmake.in-----------------------
Post by Eric Noulard
Post by Vyacheslav Karamov
Hi All!
Is it possible to change rpath at the packaging stage?
CPack is using cmake_install.cmake scripts which gets influenced
by CMAKE_INSTALL_RPATH variable and/or INSTALL_RPATH target property.
Did you try to play with that? i.e.
SET(CMAKE_INSTALL_RPATH "/opt/chatterbox")
you may try to set this in a CPACK_PROJECT_CONFIG_FILE
in order to set it to a "CPack-time" specific value.
That said I'm not sure it'll work because I don't know for sure "when exactly"
CMAKE_INSTALL_RPATH is processed, but iit's simple to try.
Post by Vyacheslav Karamov
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
SET(install_dir "/opt/chatterbox")
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH "/usr/local/lib")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
...
endif()
--
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
http://www.cmake.org/mailman/listinfo/cmake
Vyacheslav Karamov
2012-11-02 15:31:01 UTC
Permalink
Oh, that is some kind of special street magic!

RPATH is empty without these lines in CMakeLists.txt

set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake/CPackOptions.cmake)

if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND EXISTS
"${CMAKE_ROOT}/Modules/CPack.cmake")

set(CPACK_PACKAGING_INSTALL_PREFIX ${install_dir})
set(CMAKE_INSTALL_RPATH ${install_dir})
endif()
Post by Vyacheslav Karamov
Thank you very much, Eric!
It works!
----------- CMakeLists.txt ------------------
include (FindSubversion)
if (NOT Subversion_FOUND)
message(FATAL_ERROR "Please install subversion command-line client and
add its folder to the system PATH")
endif()
# Update working copy at every non-debug build
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
add_custom_target(svn_up ALL
# update the working copy
COMMAND ${Subversion_SVN_EXECUTABLE} up ${CMAKE_SOURCE_DIR}
)
endif() # if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
# Add code which adds svn revision info at every build
Subversion_WC_INFO(${CMAKE_SOURCE_DIR} ${CMAKE_PROJECT_NAME})
set(chatterbox_revision ${${CMAKE_PROJECT_NAME}_WC_REVISION})
# set product version
set (chatterbox_version_major 1)
set (chatterbox_version_minor 0)
set (chatterbox_version_patch 0)
set (chatterbox_version "${chatterbox_version_major},
${chatterbox_version_minor}, ${chatterbox_version_patch},
${chatterbox_revision}")
set(version_h_contents "/**
* Copyright (c) 2008-2012 Transparent Language, Inc. All rights reserved.
*/
#define _VESRION_NUMBER_ ${chatterbox_version}
#define _PRODUCT_NUMBER_ ${chatterbox_version}
#define _VERSION_STRING_ \"${chatterbox_version}\"
#define _PRODUCT_STRING_ \"${chatterbox_version}\"
")
#Write version.h
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/chatterbox/src/version.h"
${version_h_contents})
set (package_version
"${chatterbox_version_major}.${chatterbox_version_minor}.${chatterbox_version_patch}")
add_custom_target(configure_cpack ALL
# generate cpackoptions.cmake at build time so we get the
# most recent revision number
COMMAND ${CMAKE_COMMAND}
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
-Dproj_name=${CMAKE_PROJECT_NAME}
-Drevision=${chatterbox_revision}
-Dpack_version=${package_version}
-P ${CMAKE_SOURCE_DIR}/cmake/Create-cpackoptions.cmake
)
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug"))
add_dependencies(configure_cpack svn_up)
endif()
set(CPACK_PROJECT_CONFIG_FILE
${CMAKE_SOURCE_DIR}/cmake/CPackOptions.cmake)
----------- CMakeLists.txt ------------------
---------------Create-cpackoptions.cmake--------------
configure_file(${SOURCE_DIR}/cmake/CPackOptions.cmake.in
${SOURCE_DIR}/cmake/CPackOptions.cmake
@ONLY)
---------------Create-cpackoptions.cmake--------------
--------------------------CPackOptions.cmake.in-----------------------
set(CPACK_PACKAGE_FILE_NAME
--------------------------CPackOptions.cmake.in-----------------------
Post by Eric Noulard
Post by Vyacheslav Karamov
Hi All!
Is it possible to change rpath at the packaging stage?
CPack is using cmake_install.cmake scripts which gets influenced
by CMAKE_INSTALL_RPATH variable and/or INSTALL_RPATH target property.
Did you try to play with that? i.e.
SET(CMAKE_INSTALL_RPATH "/opt/chatterbox")
you may try to set this in a CPACK_PROJECT_CONFIG_FILE
in order to set it to a "CPack-time" specific value.
That said I'm not sure it'll work because I don't know for sure "when exactly"
CMAKE_INSTALL_RPATH is processed, but iit's simple to try.
Post by Vyacheslav Karamov
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND EXISTS
"${CMAKE_ROOT}/Modules/CPack.cmake")
SET(install_dir "/opt/chatterbox")
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH "/usr/local/lib")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
...
endif()
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.cmake.org/Wiki/CMake_FAQ
http://www.cmake.org/mailman/listinfo/cmake
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.cmake.org/Wiki/CMake_FAQ
http://www.cmake.org/mailman/listinfo/cmake
Gary Little
2012-11-02 16:29:38 UTC
Permalink
Is any time frame when CMake 2.8.10 will be added to MacPorts?

And to put my time where my mouth is, m ay I be of assistance? Are there files I can acquire that would allow me to do add it?

Gary Little
H (952) 223-1349
C (952) 454-4629
***@comcast.net
Bradley Giesbrecht
2012-11-02 16:57:02 UTC
Permalink
Post by Gary Little
Is any time frame when CMake 2.8.10 will be added to MacPorts?
And to put my time where my mouth is, m ay I be of assistance? Are there files I can acquire that would allow me to do add it?
This question is probably better asked on the MacPorts User or Dev mailing list.
http://trac.macports.org/wiki/MailingLists


Search MacPorts trac for a cmake 2.8.10 enhancement ticket.
If not found open an enhancement ticket requesting version update.
Follow ticket guidelines here like "cc maintainer":
http://trac.macports.org/wiki/TracTickets

To attach a patch to the ticket grab the current Portfile from your tree or here:
https://trac.macports.org/browser/trunk/dports/devel/cmake/Portfile

Make your changes and attache a unified diff (diff -u) to the ticket. If you are going to attach a patch add "haspatch" to the ticket keyword field.
Is all in the ticket guidelines.


Regards,
Bradley Giesbrecht (pixilla)
Rolf Eike Beer
2012-11-02 17:17:55 UTC
Permalink
Post by Vyacheslav Karamov
Thank you very much, Eric!
It works!
----------- CMakeLists.txt ------------------
include (FindSubversion)
if (NOT Subversion_FOUND)
message(FATAL_ERROR "Please install subversion command-line client and
add its folder to the system PATH")
endif()
This can be done simpler:

find_package(Subversion REQUIRED)

Eike
--

Loading...