From 6deeb5dfa50cbdb974ee9ea13f5e73301b7af6c5 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 23 Aug 2013 22:21:14 +0200 Subject: [PATCH] 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. --- cmake/Modules/OpmDoc.cmake | 2 +- cmake/Modules/OpmInit.cmake | 12 ++++++++++++ cmake/Modules/OpmInstall.cmake | 10 +++++----- cmake/Modules/OpmProject.cmake | 16 ++++++++-------- cmake/Modules/OpmSatellites.cmake | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/cmake/Modules/OpmDoc.cmake b/cmake/Modules/OpmDoc.cmake index 1871c207..f7434006 100644 --- a/cmake/Modules/OpmDoc.cmake +++ b/cmake/Modules/OpmDoc.cmake @@ -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) diff --git a/cmake/Modules/OpmInit.cmake b/cmake/Modules/OpmInit.cmake index 395cc3d1..29e4fc0b 100644 --- a/cmake/Modules/OpmInit.cmake +++ b/cmake/Modules/OpmInit.cmake @@ -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 () diff --git a/cmake/Modules/OpmInstall.cmake b/cmake/Modules/OpmInstall.cmake index 408df41d..a3467fd1 100644 --- a/cmake/Modules/OpmInstall.cmake +++ b/cmake/Modules/OpmInstall.cmake @@ -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) 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) 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) diff --git a/cmake/Modules/OpmProject.cmake b/cmake/Modules/OpmProject.cmake index 5f80a1a1..df7b01be 100644 --- a/cmake/Modules/OpmProject.cmake +++ b/cmake/Modules/OpmProject.cmake @@ -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) diff --git a/cmake/Modules/OpmSatellites.cmake b/cmake/Modules/OpmSatellites.cmake index bd95d0fc..161c79fe 100644 --- a/cmake/Modules/OpmSatellites.cmake +++ b/cmake/Modules/OpmSatellites.cmake @@ -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)