-
Notifications
You must be signed in to change notification settings - Fork 821
/
Copy pathCMakeLists.txt
130 lines (125 loc) · 4.26 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# 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.
#
#
# 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)
# For checking the compatibility of MSVC_TOOLSET_VERSION; see
# https://docs.microsoft.com/en-us/cpp/porting/overview-of-potential-upgrade-issues-visual-cpp
# Assume major version number is obtained by dropping the last decimal
# digit.
math (EXPR MSVC_TOOLSET_MAJOR "${MSVC_TOOLSET_VERSION}/10")
else ()
set (MSVC_TOOLSET_VERSION 0)
set (MSVC_TOOLSET_MAJOR 0)
endif ()
# If this is a regular build (PROJECT_SOURCE_DIR == CMAKE_SOURCE_DIR), export legacy files by default
# Otherwise, this is embedded in another project, only export PROJ target
# cf https://github.com/OSGeo/gdal/issues/5646
string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}" DEFAULT_VAL)
option(INSTALL_LEGACY_CMAKE_FILES "Install PROJ4 legacy target CMake files" ${DEFAULT_VAL})
set(PROJECT_LIST ${PROJECT_NAME})
if (INSTALL_LEGACY_CMAKE_FILES)
set(PROJECT_LIST "${PROJECT_LIST}" "${PROJECT_LEGACY_NAME}")
endif ()
foreach (PROJECT_VARIANT_NAME IN LISTS PROJECT_LIST)
string (TOLOWER "${PROJECT_VARIANT_NAME}" 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
# 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}")
if (INSTALL_LEGACY_CMAKE_FILES)
install(EXPORT targets
NAMESPACE ${PROJECT_LEGACY_NAME}::
FILE ${PROJECT_LEGACY_LOWER}-targets.cmake
DESTINATION "${CMAKECONFIGSUBDIR}")
endif()
endforeach ()