diff options
| author | Charles Karney <charles.karney@sri.com> | 2020-02-04 14:20:28 -0500 |
|---|---|---|
| committer | Charles Karney <charles.karney@sri.com> | 2020-02-04 14:20:28 -0500 |
| commit | c74781ea2710f18a9f1c9728fa5eca5d3601ad5b (patch) | |
| tree | 098b6e3fde86e89d0a2daa69976769f65b576a81 /cmake/CMakeLists.txt | |
| parent | c3e7876325e5d43586a7eee43db1df9468f90d65 (diff) | |
| download | PROJ-c74781ea2710f18a9f1c9728fa5eca5d3601ad5b.tar.gz PROJ-c74781ea2710f18a9f1c9728fa5eca5d3601ad5b.zip | |
Make PROJ the CMake project name
Allow both find_package(PROJ) and find_package(PROJ4). More details
are in cmake/CMakeLists.txt.
Diffstat (limited to 'cmake/CMakeLists.txt')
| -rw-r--r-- | cmake/CMakeLists.txt | 132 |
1 files changed, 108 insertions, 24 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 23be1f23..c790fa4a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1,9 +1,78 @@ -# proj-config.cmake for the install tree. It's installed in -# ${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.) -file(RELATIVE_PATH PROJECT_ROOT_DIR - ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIGDIR} ${CMAKE_INSTALL_PREFIX}) +# The old CMake PROJECT-NAME was PROJ4. +set (PROJECT_LEGACY_NAME PROJ4) +string (TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER) +string (TOLOWER "${PROJECT_LEGACY_NAME}" PROJECT_LEGACY_LOWER) + +# Starting with version 7.0, we install config-style find package +# files so that PROJ can be found with both +# +# find_package(PROJ) +# find_package(PROJ4) +# +# Here are the details... The command +# +# find_package(PROJ) +# +# if successful, will define variables +# +# PROJ_FOUND +# PROJ_VERSION +# PROJ_LIBRARIES = PROJ::proj +# PROJ_INCLUDE_DIRS +# etc +# +# and will define targets +# +# PROJ::proj +# PROJ4::proj +# +# Similarly +# +# find_package(PROJ4) +# +# if successful, will define variables +# +# PROJ4_FOUND +# PROJ4_VERSION +# PROJ4_LIBRARIES = PROJ4::proj +# PROJ4_INCLUDE_DIRS +# etc +# +# and will define targets +# +# PROJ::proj +# PROJ4::proj +# +# Note that targets PROJ::proj and PROJ4::proj are provided in both +# cases. However, no attempt is made to define both sets of variables +# with the two find_package options. Doing so would just lead to user +# confusion. +# +# Because pre-7.0 versions of PROJ do not support find_package (PROJ) +# and do not define a target PROJ::proj +# +# find_package(PROJ4) +# +# (instead of PROJ) should be used in any development scenarios which +# might involve (even indirectly) pre-7.0 versions of PROJ. +# +# At some future dates, find_package (PROJ4) will +# +# define PROJ4_LIBRARIES = PROJ::proj +# give WARNING message suggesting migration to find_package(PROJ) +# be disallowed via the version checking code +# +# 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 +# +# cmake/CMakeLists.txt (this file) +# cmake/project-config.cmake.in +# cmake/project-config-version.cmake.in # Variables needed by ${PROJECT_NAME_LOWER}-config-version.cmake if (MSVC) @@ -24,21 +93,36 @@ else () set (CMAKE_CROSSCOMPILING_STR "OFF") endif () -string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER) -configure_file(project-config.cmake.in project-config.cmake @ONLY) -configure_file(project-config-version.cmake.in - project-config-version.cmake @ONLY) -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/project-config.cmake" - DESTINATION "${CMAKECONFIGDIR}" - RENAME "${PROJECT_NAME_LOWER}-config.cmake") -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/project-config-version.cmake" - DESTINATION "${CMAKECONFIGDIR}" - RENAME "${PROJECT_NAME_LOWER}-config-version.cmake") -# Make information about the cmake targets (the library and the tools) -# available. -install(EXPORT targets - NAMESPACE ${PROJECT_NAME}:: - FILE ${PROJECT_NAME_LOWER}-targets.cmake - DESTINATION "${CMAKECONFIGDIR}") +foreach (PROJECT_VARIANT_NAME ${PROJECT_NAME} ${PROJECT_LEGACY_NAME}) + string (TOLOWER "${PROJECT_VARIANT_NAME}" PROJECT_VARIANT_LOWER) + set (CMAKECONFIGSUBDIR "${CMAKECONFIGDIR}/${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 + # be relocated.) + file (RELATIVE_PATH PROJECT_ROOT_DIR + ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIGSUBDIR} ${CMAKE_INSTALL_PREFIX}) + configure_file (project-config.cmake.in + project-${PROJECT_VARIANT_LOWER}-config.cmake @ONLY) + configure_file (project-config-version.cmake.in + project-${PROJECT_VARIANT_LOWER}-version.cmake @ONLY) + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/project-${PROJECT_VARIANT_LOWER}-config.cmake" + DESTINATION "${CMAKECONFIGSUBDIR}" + RENAME "${PROJECT_VARIANT_LOWER}-config.cmake") + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/project-${PROJECT_VARIANT_LOWER}-version.cmake" + DESTINATION "${CMAKECONFIGSUBDIR}" + RENAME "${PROJECT_VARIANT_LOWER}-config-version.cmake") + # Make information about the cmake targets (the library and the tools) + # available. + install(EXPORT targets + NAMESPACE ${PROJECT_NAME}:: + FILE ${PROJECT_NAME_LOWER}-targets.cmake + DESTINATION "${CMAKECONFIGSUBDIR}") + install(EXPORT targets + NAMESPACE ${PROJECT_LEGACY_NAME}:: + FILE ${PROJECT_LEGACY_LOWER}-targets.cmake + DESTINATION "${CMAKECONFIGSUBDIR}") +endforeach () + |
