diff --git a/CMakeLists.txt b/CMakeLists.txt index 2969e31cf9..43bfe95c3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -286,18 +286,8 @@ link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) # Installation ################################################################################ include(ProjInstallPath) -set(BINDIR "${DEFAULT_BINDIR}" - CACHE PATH "The directory to install binaries into.") -set(LIBDIR "${DEFAULT_LIBDIR}" - CACHE PATH "The directory to install libraries into.") -set(DATADIR "${DEFAULT_DATADIR}" - CACHE PATH "The directory to install data files into.") -set(DOCDIR "${DEFAULT_DOCDIR}" - CACHE PATH "The directory to install doc files into.") -set(INCLUDEDIR "${DEFAULT_INCLUDEDIR}" - CACHE PATH "The directory to install includes into.") -set(CMAKECONFIGDIR "${DEFAULT_CMAKEDIR}" - CACHE PATH "Parent of the directory to install cmake config files into.") +include(GNUInstallDirs) +set(PROJ_LIB_PATH "${CMAKE_INSTALL_FULL_DATADIR}/proj") ################################################################################ # Tests @@ -326,7 +316,7 @@ endif() set(docfiles COPYING NEWS AUTHORS) install(FILES ${docfiles} - DESTINATION "${DOCDIR}") + DESTINATION ${CMAKE_INSTALL_DOCDIR}) ################################################################################ # pkg-config support @@ -335,7 +325,7 @@ configure_proj_pc() install(FILES ${CMAKE_CURRENT_BINARY_DIR}/proj.pc - DESTINATION ${LIBDIR}/pkgconfig) + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") ################################################################################ # "make dist" workalike diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c790fa4a86..3854b1207c 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -64,9 +64,6 @@ string (TOLOWER "${PROJECT_LEGACY_NAME}" PROJECT_LEGACY_LOWER) # # At some more distant date, the PROJ4::proj target will be retired. # -# To support this change, the CACHE variables PROJ_CMAKE_SUBDIR (and -# CMAKECONFIGDIR) is now the "Parent of directory to install cmake -# config files into". # # All this messiness is confined to # @@ -95,7 +92,7 @@ endif () foreach (PROJECT_VARIANT_NAME ${PROJECT_NAME} ${PROJECT_LEGACY_NAME}) string (TOLOWER "${PROJECT_VARIANT_NAME}" PROJECT_VARIANT_LOWER) - set (CMAKECONFIGSUBDIR "${CMAKECONFIGDIR}/${PROJECT_VARIANT_LOWER}") + set (CMAKECONFIGSUBDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_VARIANT_LOWER}") # proj-config.cmake for the install tree. It's installed in # ${CMAKECONFIGSUBDIR} and @PROJECT_ROOT_DIR@ is the relative # path to the root from there. (Note that the whole install tree can diff --git a/cmake/ProjInstallPath.cmake b/cmake/ProjInstallPath.cmake index c7be919cb1..b995d5a003 100644 --- a/cmake/ProjInstallPath.cmake +++ b/cmake/ProjInstallPath.cmake @@ -21,58 +21,3 @@ endif() #TODO # for data install testing the PROJ_LIB envVar - -string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER) -if(UNIX OR MINGW) - include(GNUInstallDirs) - set(DEFAULT_BIN_SUBDIR ${CMAKE_INSTALL_BINDIR}) - set(DEFAULT_LIB_SUBDIR ${CMAKE_INSTALL_LIBDIR}) - set(DEFAULT_DATA_SUBDIR ${CMAKE_INSTALL_DATAROOTDIR}/proj) - set(DEFAULT_INCLUDE_SUBDIR ${CMAKE_INSTALL_INCLUDEDIR}) - set(DEFAULT_DOC_SUBDIR share/doc/${PROJECT_NAME_LOWER}) - set(DEFAULT_CMAKE_SUBDIR ${CMAKE_INSTALL_LIBDIR}/cmake) -else() - # Common locations for Unix and Mac OS X - set(DEFAULT_BIN_SUBDIR bin) - set(DEFAULT_LIB_SUBDIR lib) - set(DEFAULT_DATA_SUBDIR share/proj) - set(DEFAULT_DOC_SUBDIR doc/proj) - set(DEFAULT_INCLUDE_SUBDIR include) - set(DEFAULT_DOC_SUBDIR share/doc/proj) - set(DEFAULT_CMAKE_SUBDIR lib/cmake) - # Used for proj.pc - set(CMAKE_INSTALL_DATAROOTDIR share) -endif() - -# Locations are changeable by user to customize layout of PROJ installation -# (default values are platform-specific) -set(PROJ_BIN_SUBDIR ${DEFAULT_BIN_SUBDIR} CACHE STRING - "Subdirectory where executables will be installed") -set(PROJ_LIB_SUBDIR ${DEFAULT_LIB_SUBDIR} CACHE STRING - "Subdirectory where libraries will be installed") -set(PROJ_INCLUDE_SUBDIR ${DEFAULT_INCLUDE_SUBDIR} CACHE STRING - "Subdirectory where header files will be installed") -set(PROJ_DATA_SUBDIR ${DEFAULT_DATA_SUBDIR} CACHE STRING - "Subdirectory where data will be installed") -set(PROJ_DOC_SUBDIR ${DEFAULT_DOC_SUBDIR} CACHE STRING - "Subdirectory where doc will be installed") -set(PROJ_CMAKE_SUBDIR ${DEFAULT_CMAKE_SUBDIR} CACHE STRING - "Parent of subdirectory where cmake proj-config file will be installed") - -# Mark *DIR variables as advanced and dedicated to use by power-users only. -mark_as_advanced( - PROJ_ROOT_DIR - PROJ_BIN_SUBDIR - PROJ_LIB_SUBDIR - PROJ_INCLUDE_SUBDIR - PROJ_DATA_SUBDIR - PROJ_DOC_SUBDIR - PROJ_CMAKE_SUBDIR -) - -set(DEFAULT_BINDIR "${PROJ_BIN_SUBDIR}") -set(DEFAULT_LIBDIR "${PROJ_LIB_SUBDIR}") -set(DEFAULT_DATADIR "${PROJ_DATA_SUBDIR}") -set(DEFAULT_DOCDIR "${PROJ_DOC_SUBDIR}") -set(DEFAULT_INCLUDEDIR "${PROJ_INCLUDE_SUBDIR}") -set(DEFAULT_CMAKEDIR "${PROJ_CMAKE_SUBDIR}") diff --git a/cmake/ProjMac.cmake b/cmake/ProjMac.cmake index d566ef0edc..d91ab66c0e 100644 --- a/cmake/ProjMac.cmake +++ b/cmake/ProjMac.cmake @@ -22,7 +22,9 @@ if(APPLE) option(BUILD_FRAMEWORKS_AND_BUNDLE "if set to ON, build a library framework and application bundle, \ otherwise install classical UNIX bin/lib" OFF) - set(DEFAULT_BINDIR ${BUNDLEDIR}) + if(BUILD_FRAMEWORKS_AND_BUNDLE) + set(CMAKE_INSTALL_BINDIR ${BUNDLEDIR}) + endif() print_variable(BUNDLEDIR) print_variable(PROJ_INSTALL_NAME_DIR) print_variable(FRAMEWORKDIR) diff --git a/cmake/ProjUtilities.cmake b/cmake/ProjUtilities.cmake index f0853fe315..78044b9d74 100644 --- a/cmake/ProjUtilities.cmake +++ b/cmake/ProjUtilities.cmake @@ -68,10 +68,9 @@ endfunction() # function(configure_proj_pc) - set(prefix "${CMAKE_INSTALL_PREFIX}") - set(exec_prefix "$\{prefix\}") - set(libdir "$\{exec_prefix\}/${PROJ_LIB_SUBDIR}") - set(includedir "$\{prefix\}/${PROJ_INCLUDE_SUBDIR}") + set(prefix ${CMAKE_INSTALL_PREFIX}) + set(libdir "$\{prefix\}/${CMAKE_INSTALL_LIBDIR}") + set(includedir "$\{prefix\}/${CMAKE_INSTALL_INCLUDEDIR}") set(datarootdir "$\{prefix\}/${CMAKE_INSTALL_DATAROOTDIR}") set(datadir "$\{datarootdir\}") set(PACKAGE "proj") diff --git a/cmake/project-config.cmake.in b/cmake/project-config.cmake.in index 23f997abd5..a1d3bd329d 100644 --- a/cmake/project-config.cmake.in +++ b/cmake/project-config.cmake.in @@ -11,9 +11,10 @@ # Tell the user project where to find our headers and libraries get_filename_component (_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) get_filename_component (_ROOT "${_DIR}/@PROJECT_ROOT_DIR@" ABSOLUTE) -set (@PROJECT_VARIANT_NAME@_INCLUDE_DIRS "${_ROOT}/@INCLUDEDIR@") -set (@PROJECT_VARIANT_NAME@_LIBRARY_DIRS "${_ROOT}/@LIBDIR@") -set (@PROJECT_VARIANT_NAME@_BINARY_DIRS "${_ROOT}/@BINDIR@") +# Use _ROOT as prefix here for the possibility of relocation after installation. +set (@PROJECT_VARIANT_NAME@_INCLUDE_DIRS "${_ROOT}/@CMAKE_INSTALL_INCLUDEDIR@") +set (@PROJECT_VARIANT_NAME@_LIBRARY_DIRS "${_ROOT}/@CMAKE_INSTALL_LIBDIR@") +set (@PROJECT_VARIANT_NAME@_BINARY_DIRS "${_ROOT}/@CMAKE_INSTALL_BINDIR@") set (@PROJECT_VARIANT_NAME@_LIBRARIES @PROJECT_VARIANT_NAME@::proj) # Read in the exported definition of the library diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index d460d371aa..032c491389 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -101,5 +101,5 @@ set(ALL_DATA_FILE ) install( FILES ${ALL_DATA_FILE} - DESTINATION ${DATADIR} + DESTINATION ${PROJ_LIB_PATH} ) diff --git a/include/proj/CMakeLists.txt b/include/proj/CMakeLists.txt index 0d9abee3bd..f9c727a028 100644 --- a/include/proj/CMakeLists.txt +++ b/include/proj/CMakeLists.txt @@ -1,7 +1,5 @@ -set(installdest ${INCLUDEDIR}/proj) - install( FILES util.hpp metadata.hpp common.hpp crs.hpp datum.hpp coordinatesystem.hpp coordinateoperation.hpp io.hpp nn.hpp - DESTINATION ${installdest} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/proj ) diff --git a/proj.pc.in b/proj.pc.in index 9855aadccf..641bab16c5 100644 --- a/proj.pc.in +++ b/proj.pc.in @@ -1,5 +1,4 @@ prefix=@prefix@ -exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ datarootdir=@datarootdir@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 01e069794a..6ba505b37e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,5 +9,5 @@ add_subdirectory(tests) if(APPLE) # Directory name for installed targets - set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LIBDIR}") + set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_FULL_LIBDIR}) endif() diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index 0f16ef91ba..cdd85bd36b 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -29,9 +29,9 @@ if(NOT MSVC) # Use relative path so that package is relocatable if(APPLE) - set(CMAKE_INSTALL_RPATH "@loader_path/../${LIBDIR}") + set(CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}") else() - set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${LIBDIR}") + set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") endif() # Other apps can link to libproj using e.g. LDFLAGS -Wl,-rpath,${prefix}/lib diff --git a/src/apps/bin_cct.cmake b/src/apps/bin_cct.cmake index 94b0f87898..403733fb19 100644 --- a/src/apps/bin_cct.cmake +++ b/src/apps/bin_cct.cmake @@ -11,4 +11,4 @@ add_executable(cct ${CCT_SRC} ${CCT_INCLUDE}) target_link_libraries(cct PRIVATE ${PROJ_LIBRARIES}) install(TARGETS cct - DESTINATION ${BINDIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/apps/bin_cs2cs.cmake b/src/apps/bin_cs2cs.cmake index c5e82478f2..a9f77c7b93 100644 --- a/src/apps/bin_cs2cs.cmake +++ b/src/apps/bin_cs2cs.cmake @@ -10,4 +10,4 @@ add_executable(cs2cs ${CS2CS_SRC} ${CS2CS_INCLUDE}) target_link_libraries(cs2cs PRIVATE ${PROJ_LIBRARIES}) install(TARGETS cs2cs - DESTINATION ${BINDIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/apps/bin_geod.cmake b/src/apps/bin_geod.cmake index 4fa419779c..8466898dff 100644 --- a/src/apps/bin_geod.cmake +++ b/src/apps/bin_geod.cmake @@ -12,7 +12,7 @@ add_executable(geod ${GEOD_SRC} ${GEOD_INCLUDE}) target_link_libraries(geod PRIVATE ${PROJ_LIBRARIES}) install(TARGETS geod - DESTINATION ${BINDIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) # invgeod target: symlink or copy of geod executable @@ -32,7 +32,7 @@ if(UNIX) add_custom_target(invgeod ALL DEPENDS ${link_target}) - install(FILES ${link_target} DESTINATION ${BINDIR}) + install(FILES ${link_target} DESTINATION ${CMAKE_INSTALL_BINDIR}) else() @@ -40,6 +40,6 @@ else() target_link_libraries(invgeod PRIVATE ${PROJ_LIBRARIES}) install(TARGETS invgeod - DESTINATION ${BINDIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/src/apps/bin_gie.cmake b/src/apps/bin_gie.cmake index 8e2d227838..f3079735c9 100644 --- a/src/apps/bin_gie.cmake +++ b/src/apps/bin_gie.cmake @@ -12,5 +12,5 @@ target_link_libraries(gie PRIVATE ${PROJ_LIBRARIES}) if(BUILD_GIE) install(TARGETS gie - DESTINATION ${BINDIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/src/apps/bin_proj.cmake b/src/apps/bin_proj.cmake index 86232f591c..b410e63bb1 100644 --- a/src/apps/bin_proj.cmake +++ b/src/apps/bin_proj.cmake @@ -13,7 +13,7 @@ set_target_properties(binproj target_link_libraries(binproj PRIVATE ${PROJ_LIBRARIES}) install(TARGETS binproj - DESTINATION ${BINDIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) # invproj target: symlink or copy of proj executable @@ -33,7 +33,7 @@ if(UNIX) add_custom_target(invproj ALL DEPENDS ${link_target}) - install(FILES ${link_target} DESTINATION ${BINDIR}) + install(FILES ${link_target} DESTINATION ${CMAKE_INSTALL_BINDIR}) else() @@ -41,6 +41,6 @@ else() target_link_libraries(invproj PRIVATE ${PROJ_LIBRARIES}) install(TARGETS invproj - DESTINATION ${BINDIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/src/apps/bin_projinfo.cmake b/src/apps/bin_projinfo.cmake index e5b03424be..6bd6355ad4 100644 --- a/src/apps/bin_projinfo.cmake +++ b/src/apps/bin_projinfo.cmake @@ -6,7 +6,7 @@ add_executable(projinfo ${PROJINFO_SRC}) target_link_libraries(projinfo PRIVATE ${PROJ_LIBRARIES}) install(TARGETS projinfo - DESTINATION ${BINDIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) if(CURL_ENABLED) target_compile_definitions(projinfo PRIVATE -DCURL_ENABLED) diff --git a/src/apps/bin_projsync.cmake b/src/apps/bin_projsync.cmake index c51d28da9c..3f24fb398b 100644 --- a/src/apps/bin_projsync.cmake +++ b/src/apps/bin_projsync.cmake @@ -6,4 +6,4 @@ add_executable(projsync ${PROJSYNC_SRC}) target_link_libraries(projsync PRIVATE ${PROJ_LIBRARIES}) install(TARGETS projsync - DESTINATION ${BINDIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake index 986f499e61..da0cc1290d 100644 --- a/src/lib_proj.cmake +++ b/src/lib_proj.cmake @@ -294,7 +294,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) source_group("CMake Files" FILES CMakeLists.txt) # Embed PROJ_LIB data files location -add_definitions(-DPROJ_LIB="${CMAKE_INSTALL_PREFIX}/${DATADIR}") +add_definitions(-DPROJ_LIB="${PROJ_LIB_PATH}") ########################################################### @@ -399,7 +399,7 @@ endif() target_include_directories(proj INTERFACE $ $ - $) + $) if(WIN32) set_target_properties(proj @@ -487,14 +487,14 @@ endif() ############################################## install(TARGETS proj EXPORT targets - RUNTIME DESTINATION ${BINDIR} - LIBRARY DESTINATION ${LIBDIR} - ARCHIVE DESTINATION ${LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} FRAMEWORK DESTINATION ${FRAMEWORKDIR}) if(NOT BUILD_FRAMEWORKS_AND_BUNDLE) install(FILES ${ALL_LIBPROJ_HEADERS} - DESTINATION ${INCLUDEDIR}) + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() ##############################################