Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/kicklib2/cmake/InstallConfig.cmake @ 8703

Last change on this file since 8703 was 8318, checked in by rgrieder, 14 years ago

RPATH handling was broken in certain cases, esp. for "turn-key" (INSTALL_COPYABLE) installations.
Fixed by using the "$ORIGIN" token and distinguishing between executable, library and module when setting the RPATH.

  • Property svn:eol-style set to native
File size: 4.1 KB
RevLine 
[2579]1 #
[2626]2 #             ORXONOX - the hottest 3D action shooter ever to exist
3 #                             > www.orxonox.net <
[2579]4 #
[2626]5 #        This program is free software; you can redistribute it and/or
6 #         modify it under the terms of the GNU General Public License
7 #        as published by the Free Software Foundation; either version 2
8 #            of the License, or (at your option) any later version.
[2579]9 #
[2626]10 #       This program is distributed in the hope that it will be useful,
11 #        but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #                 GNU General Public License for more details.
[2579]14 #
[2626]15 #   You should have received a copy of the GNU General Public License along
16 #      with this program; if not, write to the Free Software Foundation,
17 #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
[2579]18 #
19 #
[2626]20 #  Author:
21 #    Reto Grieder
22 #  Description:
[5664]23 #    Configures the installation (paths, rpaths, options)
[2579]24 #
25
[5667]26IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # Variable provided by CMake
27  IF("$ENV{ORXONOX_DEV}" OR TARDIS)
28    SET(_install_prefix_changed 1)
29    SET(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH
30        "Install path prefix, prepended onto install directories." FORCE)
31  ENDIF()
32ENDIF()
33
[2702]34SET(_info_text "Puts all installed files in subfolders of the install prefix path. That root folder can then be moved, copied and renamed as you wish. The executable will not write to folders like ~/.orxonox or \"Applictation Data\"")
[5667]35IF(UNIX AND NOT _install_prefix_changed)
[2702]36  OPTION(INSTALL_COPYABLE "${_info_text}" FALSE)
37ELSE()
38  OPTION(INSTALL_COPYABLE "${_info_text}" TRUE)
39ENDIF()
40
[8317]41# Default relative installation paths
42SET(RUNTIME_INSTALL_DIRECTORY ${DEFAULT_RUNTIME_PATH})
43SET(LIBRARY_INSTALL_DIRECTORY ${DEFAULT_LIBRARY_PATH})
44SET(ARCHIVE_INSTALL_DIRECTORY ${DEFAULT_ARCHIVE_PATH})
45SET(MODULE_INSTALL_DIRECTORY  ${DEFAULT_MODULE_PATH})
46SET(DOC_INSTALL_DIRECTORY     ${DEFAULT_DOC_PATH})
47SET(DATA_INSTALL_DIRECTORY    ${DEFAULT_DATA_PATH})
48SET(CONFIG_INSTALL_DIRECTORY  ${DEFAULT_CONFIG_PATH})
49SET(LOG_INSTALL_DIRECTORY     ${DEFAULT_LOG_PATH})
[2702]50
[5641]51IF(NOT INSTALL_COPYABLE)
[8317]52  IF(LINUX)
[5641]53    # Using absolute paths
[8317]54    SET(RUNTIME_INSTALL_DIRECTORY games)
55    SET(LIBRARY_INSTALL_DIRECTORY lib/games/orxonox)
56    SET(ARCHIVE_INSTALL_DIRECTORY lib/games/orxonox/static)
57    SET(MODULE_INSTALL_DIRECTORY  lib/games/orxonox/modules)
58    SET(DOC_INSTALL_DIRECTORY     share/doc/orxonox)
59    SET(DATA_INSTALL_DIRECTORY    share/games/orxonox)
60  ELSEIF(WIN32)
61    # Leave on default (installs to only one location anyway)
62  ELSEIF(APPLE)
63    # TODO: Figure out what's the best way to install the application
[5641]64  ENDIF()
[2687]65
[2702]66  # Leave empty because it is user and therefore runtime dependent
[5641]67  SET(CONFIG_INSTALL_DIRECTORY)
68  SET(LOG_INSTALL_DIRECTORY)
[2657]69ENDIF()
70
[2673]71################## Unix rpath ###################
[2657]72
[8318]73# Use, i.e. don't skip the full RPATH for the build tree
74SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
75
[5664]76# When building, don't use the install RPATH already
[2657]77# (but later on when installing)
[5695]78SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
[2657]79
[5664]80# The RPATH to be used when installing
[5641]81IF(INSTALL_COPYABLE)
[8318]82  # Get relative paths from run to lib and from module to lib directory.
83  FILE(RELATIVE_PATH _runtime_rpath "/${RUNTIME_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
84  FILE(RELATIVE_PATH _module_rpath  "/${MODULE_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
85  # $ORIGIN (with $ escaped) refers to the actual location of the library
86  # The UNIX loader recognises this special variable
87  SET(RUNTIME_RPATH "\$ORIGIN/${_runtime_rpath}")
88  SET(LIBRARY_RPATH "\$ORIGIN")
89  SET(MODULE_RPATH  "\$ORIGIN:\$ORIGIN/${_module_rpath}")
[5641]90ELSE()
[8318]91  SET(RUNTIME_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}")
92  SET(LIBRARY_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}")
93  SET(MODULE_RPATH  "${LIBRARY_RPATH}:${CMAKE_INSTALL_PREFIX}/${MODULE_INSTALL_DIRECTORY}")
[5641]94ENDIF()
[2657]95
[5664]96# Add the automatically determined parts of the RPATH
[2657]97# which point to directories outside the build tree to the install RPATH
98SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
Note: See TracBrowser for help on using the repository browser.