Support installation in a versioned directory

If the option USE_VERSIONED_DIR is set to ON (default is OFF), then
most files are installed in a ${suite}-${label}/ subdirectory
(e.g. header files go in "/usr/include/opm-2013.03/"). This enables
us to easily install backports of newer versions on systems which
have a system package for an older one, without getting conflicts.
This commit is contained in:
Roland Kaufmann 2013-08-23 22:21:14 +02:00
parent 433d33e008
commit 8c71f4d75b
5 changed files with 27 additions and 15 deletions

View File

@ -44,7 +44,7 @@ macro (opm_doc opm doxy_dir)
# to direct where the install target should put the documentation. the names
# here are taken from GNUInstallDirs.cmake
set (CMAKE_INSTALL_DATAROOTDIR "share" CACHE STRING "Read-only arch.-indep. data root")
set (CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${${opm}_NAME}" CACHE STRING "Documentation root")
set (CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc${${opm}_VER_DIR}/${${opm}_NAME}" CACHE STRING "Documentation root")
set (_formats html)
foreach (format IN LISTS _formats)
string (TOUPPER ${format} FORMAT)

View File

@ -59,3 +59,15 @@ endmacro ()
OpmInitProjVars ()
OpmInitDirVars ()
# if we are backporting this release to a system which already have an
# earlier version, set this flag to have everything scoped into a directory
# which incorporates the label of the release. this is done by interjecting
# the ${project}_VER_DIR into the installation path.
option (USE_VERSIONED_DIR "Put files in release-specific directories" OFF)
set (${project}_SUITE "opm")
if (USE_VERSIONED_DIR)
set (${project}_VER_DIR "/${${project}_SUITE}-${${project}_LABEL}")
else ()
set (${project}_VER_DIR "")
endif ()

View File

@ -15,13 +15,13 @@ macro (opm_install opm)
file (RELATIVE_PATH _rel_dir "${PROJECT_SOURCE_DIR}" "${_dir}")
install (
FILES ${_hdr}
DESTINATION include/${_rel_dir}
DESTINATION include${${opm}_VER_DIR}/${_rel_dir}
)
endforeach (_hdr)
install (
TARGETS ${${opm}_TARGET}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR}
)
# only /usr/lib/debug seems to be searched for debug info; if we have
# write access to that directory (package installation), then default
@ -45,11 +45,11 @@ macro (opm_install opm)
if (${opm}_LIBRARY_TYPE STREQUAL "SHARED" AND ${opm}_TARGET AND ${opm}_DEBUG)
install (
FILES ${PROJECT_BINARY_DIR}/${${opm}_DEBUG}
DESTINATION ${_dbg_prefix}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
DESTINATION ${_dbg_prefix}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR}
)
endif (${opm}_LIBRARY_TYPE STREQUAL "SHARED" AND ${opm}_TARGET AND ${opm}_DEBUG)
install (
FILES ${PROJECT_SOURCE_DIR}/dune.module
DESTINATION ${CMAKE_INSTALL_LIBDIR_NOARCH}/dunecontrol/${${opm}_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR_NOARCH}${${opm}_VER_DIR}/dunecontrol/${${opm}_NAME}
)
endmacro (opm_install opm)

View File

@ -94,18 +94,18 @@ function (opm_cmake_config name)
# variables that contains build paths
string (REPLACE
"${PROJECT_SOURCE_DIR}"
"${CMAKE_INSTALL_PREFIX}/include"
"${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}"
${name}_INCLUDE_DIRS
"${${name}_INCLUDE_DIRS}"
)
string (REPLACE
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}"
${name}_LIBRARY
"${${name}_LIBRARY}"
)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}"
)
# create a config mode file which targets the install directory instead
# of the build directory (using the same input template)
@ -117,13 +117,13 @@ function (opm_cmake_config name)
# this file gets copied to the final installation directory
install (
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.cmake
DESTINATION share/cmake/${${name}_NAME}
DESTINATION share/cmake${${name}_VER_DIR}/${${name}_NAME}
RENAME ${${name}_NAME}-config.cmake
)
# assume that there exists a version file already
install (
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-config-version.cmake
DESTINATION share/cmake/${${name}_NAME}
DESTINATION share/cmake${${name}_VER_DIR}/${${name}_NAME}
)
# find-mode .pc file; use this to locate system installation
@ -132,14 +132,14 @@ function (opm_cmake_config name)
${template_dir}/opm-project.pc.in
${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
${CMAKE_INSTALL_PREFIX}
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
${CMAKE_INSTALL_PREFIX}/include
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}
${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}
)
# put this in the right system location; assume that we have binaries
install (
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig/
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig${${name}_VER_DIR}/
RENAME ${${name}_NAME}.pc
)
endfunction (opm_cmake_config name)

View File

@ -101,7 +101,7 @@ macro (opm_compile_satellites opm satellite excl_all test_regexp)
list (FIND ${satellite}_SOURCES_DIST "${_sat_FILE}" _is_util)
if (NOT (_is_util EQUAL -1))
install (TARGETS ${_sat_NAME} RUNTIME
DESTINATION bin/
DESTINATION bin${${opm}_VER_DIR}/
)
endif (NOT (_is_util EQUAL -1))
endforeach (_sat_FILE)