aboutsummaryrefslogtreecommitdiff
path: root/cmake/CMakeLists.txt
diff options
context:
space:
mode:
authorNicolas David <nicolas.david@ign.fr>2017-09-25 21:05:46 +0200
committerHoward Butler <howard@hobu.co>2017-09-25 14:05:46 -0500
commit6ea5a3cbe601bc14cb18614fdaa97092abf96f3c (patch)
tree6a5c424cd836b617354b9222b4396548d9a232e4 /cmake/CMakeLists.txt
parent03750c1961d2978773ac0b4a0423b1cdcc2c6453 (diff)
downloadPROJ-6ea5a3cbe601bc14cb18614fdaa97092abf96f3c.tar.gz
PROJ-6ea5a3cbe601bc14cb18614fdaa97092abf96f3c.zip
fix #560 install cmake config file to lib and use GNUInstallDirs on Unix (#561)
* fix #560 install proj4-config.cmake to defaut path * add some variable and cmake option to specify where the cmake config file should be installed. * change project_root_dir use in project-config.cmake.in variable from hard coded path to computed path with file(RELATIVE_PATH) function. * Still use the old project-config.cmake/configure_file way of generate config file. A cleaner way could be to use the modern cmake export(target ..) * use GNUInstallDirs for default unix install path
Diffstat (limited to 'cmake/CMakeLists.txt')
-rw-r--r--cmake/CMakeLists.txt14
1 files changed, 4 insertions, 10 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 742da0e9..0fcde0ca 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -2,13 +2,7 @@
# ${INSTALL_CMAKE_DIR} and @PROJECT_ROOT_DIR@ is the relative
# path to the root from there. (Note that the whole install tree can
# be relocated.)
-if (NOT WIN32)
- set (INSTALL_CMAKE_DIR "share/cmake/${PROJECT_NAME}")
- set (PROJECT_ROOT_DIR "../../..")
-else ()
- set (INSTALL_CMAKE_DIR "cmake")
- set (PROJECT_ROOT_DIR "..")
-endif ()
+file(RELATIVE_PATH PROJECT_ROOT_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIGDIR} ${CMAKE_INSTALL_PREFIX})
string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER)
configure_file (project-config.cmake.in project-config.cmake @ONLY)
@@ -16,14 +10,14 @@ configure_file (project-config-version.cmake.in
project-config-version.cmake @ONLY)
install (FILES
"${CMAKE_CURRENT_BINARY_DIR}/project-config.cmake"
- DESTINATION "${INSTALL_CMAKE_DIR}"
+ DESTINATION "${CMAKECONFIGDIR}"
RENAME "${PROJECT_NAME_LOWER}-config.cmake")
install (FILES
"${CMAKE_CURRENT_BINARY_DIR}/project-config-version.cmake"
- DESTINATION "${INSTALL_CMAKE_DIR}"
+ DESTINATION "${CMAKECONFIGDIR}"
RENAME "${PROJECT_NAME_LOWER}-config-version.cmake")
# Make information about the cmake targets (the library and the tools)
# available.
install (EXPORT targets
FILE ${PROJECT_NAME_LOWER}-targets.cmake
- DESTINATION "${INSTALL_CMAKE_DIR}")
+ DESTINATION "${CMAKECONFIGDIR}")