forked from locationtech/geomesa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
403 lines (349 loc) · 13.2 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
################################################################################
#
# This file is part of CMake configuration for PROJ library (inspired from SOCI
# CMake, Copyright (C) 2009-2010 Mateusz Loskot <[email protected]> )
#
# Copyright (C) 2011 Nicolas David <[email protected]>
# Distributed under the MIT license
#
################################################################################
# General settings
################################################################################
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(PROJ
DESCRIPTION "PROJ coordinate transformation software library"
LANGUAGES C CXX
)
# Only interpret if() arguments as variables or keywords when unquoted
cmake_policy(SET CMP0054 NEW)
# Set C++ version
# Make CMAKE_CXX_STANDARD available as cache option overridable by user
set(CMAKE_CXX_STANDARD 11
CACHE STRING "C++ standard version to use (default is 11)")
message(STATUS "Requiring C++${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
message(STATUS "Requiring C++${CMAKE_CXX_STANDARD} - done")
# Set C99 version
# Make CMAKE_C_STANDARD available as cache option overridable by user
set(CMAKE_C_STANDARD 99
CACHE STRING "C standard version to use (default is 99)")
message(STATUS "Requiring C${CMAKE_C_STANDARD}")
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
message(STATUS "Requiring C${CMAKE_C_STANDARD} - done")
# Set global -fvisibility=hidden
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
# Set warnings as variables, then store as cache options
set(PROJ_common_WARN_FLAGS # common only to GNU/Clang C/C++
-Wall
-Wextra
-Wswitch
-Wshadow
-Wunused-parameter
-Wmissing-declarations
-Wformat
-Wformat-security
)
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
set(PROJ_C_WARN_FLAGS ${PROJ_common_WARN_FLAGS}
-Wmissing-prototypes
)
set(PROJ_CXX_WARN_FLAGS ${PROJ_common_WARN_FLAGS})
elseif("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
set(PROJ_C_WARN_FLAGS ${PROJ_common_WARN_FLAGS}
-Wmissing-prototypes
-Wfloat-conversion
-Wc11-extensions
)
set(PROJ_CXX_WARN_FLAGS ${PROJ_common_WARN_FLAGS}
-Wfloat-conversion
)
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
add_definitions(/D_CRT_SECURE_NO_WARNINGS) # Eliminate deprecation warnings
set(PROJ_C_WARN_FLAGS
/W4
/wd4706 # Suppress warning about assignment within conditional expression
/wd4996 # Suppress warning about sprintf, etc., being unsafe
)
if("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "arm64")
# Suppress an inaccurate warning when compiling for an MSVC/ARM64 platform
# It incorrectly assumes a division by zero is possible despite a check
set(PROJ_C_WARN_FLAGS ${PROJ_C_WARN_FLAGS} /wd4723)
endif()
set(PROJ_CXX_WARN_FLAGS /EHsc ${PROJ_C_WARN_FLAGS})
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
if(MSVC)
set(PROJ_C_WARN_FLAGS /Wall)
set(PROJ_CXX_WARN_FLAGS /Wall)
else()
set(PROJ_C_WARN_FLAGS -Wall)
set(PROJ_CXX_WARN_FLAGS -Wall)
endif()
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
# Intel CXX compiler based on clang defaults to -ffast-math, which
# breaks std::isinf(), std::isnan(), etc.
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fno-fast-math)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fno-fast-math)
endif ()
set(PROJ_C_WARN_FLAGS "${PROJ_C_WARN_FLAGS}"
CACHE STRING "C flags used to compile PROJ targets")
set(PROJ_CXX_WARN_FLAGS "${PROJ_CXX_WARN_FLAGS}"
CACHE STRING "C++ flags used to compile PROJ targets")
################################################################################
# PROJ CMake modules
################################################################################
# Path to additional CMake modules
set(CMAKE_MODULE_PATH ${PROJ_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
include(ProjUtilities)
message(STATUS "Configuring PROJ:")
################################################################################
#PROJ version information
################################################################################
include(ProjVersion)
proj_version(MAJOR 9 MINOR 2 PATCH 0)
set(PROJ_SOVERSION 25)
set(PROJ_BUILD_VERSION "${PROJ_SOVERSION}.${PROJ_VERSION}")
################################################################################
# Build features and variants
################################################################################
include(Ccache)
include(ProjConfig)
include(ProjMac)
include(policies)
################################################################################
# Check for nlohmann_json
################################################################################
set(NLOHMANN_JSON_ORIGIN "auto" CACHE STRING
"nlohmann/json origin. The default auto will try to use external \
nlohmann/json if possible")
set_property(CACHE NLOHMANN_JSON_ORIGIN PROPERTY STRINGS auto internal external)
# Probably not the strictest minimum, but known to work with it
set(MIN_NLOHMANN_JSON_VERSION 3.7.0)
if(NLOHMANN_JSON_ORIGIN STREQUAL "external")
find_package(nlohmann_json REQUIRED)
set(NLOHMANN_JSON "external")
elseif(NLOHMANN_JSON_ORIGIN STREQUAL "internal")
set(NLOHMANN_JSON "internal")
else()
find_package(nlohmann_json QUIET)
if(nlohmann_json_FOUND)
set(NLOHMANN_JSON "external")
else()
set(NLOHMANN_JSON "internal")
endif()
endif()
if(NLOHMANN_JSON STREQUAL "external")
# Check minimum version
if(nlohmann_json_VERSION VERSION_LESS MIN_NLOHMANN_JSON_VERSION)
message(STATUS "external nlohmann/json version ${nlohmann_json_VERSION} "
"is older than minimum requirement ${MIN_NLOHMANN_JSON_VERSION}")
set(NLOHMANN_JSON "internal")
else()
message(STATUS "found nlohmann/json version ${nlohmann_json_VERSION}")
endif()
endif()
message(STATUS "nlohmann/json: ${NLOHMANN_JSON}")
################################################################################
# Check for sqlite3
################################################################################
find_program(EXE_SQLITE3 sqlite3)
if(NOT EXE_SQLITE3)
message(SEND_ERROR "sqlite3 binary not found!")
endif()
find_package(Sqlite3 REQUIRED)
if(NOT SQLITE3_FOUND)
message(SEND_ERROR "sqlite3 dependency not found!")
endif()
# Would build and run with older versions, but with horrible performance
# See https://github.com/OSGeo/PROJ/issues/1718
if("${SQLITE3_VERSION}" VERSION_LESS "3.11")
message(SEND_ERROR "sqlite3 >= 3.11 required!")
endif()
################################################################################
# Check for libtiff
################################################################################
option(ENABLE_TIFF "Enable TIFF support to read some grids" ON)
mark_as_advanced(ENABLE_TIFF)
set(TIFF_ENABLED FALSE)
if(ENABLE_TIFF)
find_package(TIFF REQUIRED)
if(TIFF_FOUND)
set(TIFF_ENABLED TRUE)
else()
message(SEND_ERROR
"libtiff dependency not found! Use ENABLE_TIFF=OFF to force it off")
endif()
else()
message(WARNING
"TIFF support is not enabled and will result in the inability to read "
"some grids")
endif()
################################################################################
# Check for curl
################################################################################
option(ENABLE_CURL "Enable Curl support" ON)
set(CURL_ENABLED FALSE)
if(ENABLE_CURL)
find_package(CURL REQUIRED)
if(CURL_FOUND)
set(CURL_ENABLED TRUE)
# Target CURL::libcurl only defined since CMake 3.12
# TODO: remove this when CMake >= 3.12 required
if(NOT TARGET CURL::libcurl)
add_library(CURL::libcurl INTERFACE IMPORTED)
set_target_properties(CURL::libcurl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${CURL_LIBRARIES}"
)
endif()
else()
message(SEND_ERROR "curl dependency not found!")
endif()
endif()
################################################################################
if(DEFINED PROJ_LIB_ENV_VAR_TRIED_LAST)
set(PROJ_DATA_ENV_VAR_TRIED_LAST ${PROJ_LIB_ENV_VAR_TRIED_LAST})
message(WARNING "PROJ_LIB_ENV_VAR_TRIED_LAST option has been renamed to PROJ_DATA_ENV_VAR_TRIED_LAST. PROJ_LIB_ENV_VAR_TRIED_LAST is still working for now, but may be completely replaced by PROJ_DATA_ENV_VAR_TRIED_LAST in a future release")
else()
option(PROJ_DATA_ENV_VAR_TRIED_LAST "Whether the PROJ_DATA environment variable should be tried after the hardcoded location" OFF)
endif()
if(PROJ_DATA_ENV_VAR_TRIED_LAST)
add_definitions(-DPROJ_DATA_ENV_VAR_TRIED_LAST)
endif()
################################################################################
# threading configuration
################################################################################
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads)
if(Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
set(CMAKE_REQUIRED_LIBRARIES
"${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}")
endif()
include(CheckCSourceCompiles)
if(MSVC)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} /WX /W4")
else()
set(CMAKE_REQUIRED_LIBRARIES m)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall")
endif()
# Set a default build type for single-configuration cmake generators if
# no build type is set.
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if(MSVC OR CMAKE_CONFIGURATION_TYPES)
# For multi-config systems and for Visual Studio, the debug version of
# the library has _d appended.
set(CMAKE_DEBUG_POSTFIX _d)
endif()
# Put the libraries and binaries that get built into directories at the
# top of the build tree rather than in hard-to-find leaf
# directories. This simplifies manual testing and the use of the build
# tree rather than installed PROJ libraries.
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJ_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJ_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJ_BINARY_DIR}/bin)
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
################################################################################
# Installation
################################################################################
include(ProjInstallPath)
# By default GNUInstallDirs will use the upper case project name
# for CMAKE_INSTALL_DOCDIR, resulting in something like share/doc/PROJ
# instead of share/doc/proj which historically have been the path used
# by the project.
# Here force the use of a lower case project name and reset after
# GNUInstallDirs has done its thing
set(PROJECT_NAME_ORIGINAL "${PROJECT_NAME}")
string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME)
include(GNUInstallDirs)
set(PROJECT_NAME "${PROJECT_NAME_ORIGINAL}")
set(PROJ_DATA_PATH "${CMAKE_INSTALL_FULL_DATADIR}/proj")
################################################################################
# Tests
################################################################################
include(CTest)
if(BUILD_TESTING)
include(ProjTest)
else()
message(STATUS "Testing disabled")
endif()
################################################################################
# Build configured components
################################################################################
include_directories(${PROJ_SOURCE_DIR}/src)
add_subdirectory(data)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(man)
add_subdirectory(cmake)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
set(docfiles COPYING NEWS AUTHORS)
install(FILES ${docfiles}
DESTINATION ${CMAKE_INSTALL_DOCDIR})
################################################################################
# pkg-config support
################################################################################
configure_proj_pc()
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/proj.pc
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
################################################################################
# "make dist" workalike
################################################################################
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "proj-${PROJ_VERSION}")
set(CPACK_PACKAGE_VENDOR "OSGeo")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJ_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJ_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJ_VERSION_PATCH})
set(CPACK_VERBATIM_VARIABLES TRUE)
set(CPACK_SOURCE_IGNORE_FILES
/\\..* # any file/directory starting with .
/.*\\.yml
/.*\\.gz
/.*\\.zip
/.*build.*/
\\.deps
/autogen\\.sh
/autom4te\\.cache
/CODE_OF_CONDUCT.md
/CONTRIBUTING.md
/Dockerfile
/docs/
/Doxyfile
/examples/
/HOWTO-RELEASE
/m4/lt*
/m4/libtool*
/media/
/schemas/
/scripts/
/test/fuzzers/
/test/gigs/.*gie\\.failing
/test/postinstall/
/travis/
${PROJECT_BINARY_DIR}
)
include(CPack)
# Simplify README.md to README
add_custom_target(README
COMMAND ${CMAKE_COMMAND}
-D PROJ_SOURCE_DIR=${PROJ_SOURCE_DIR}
-P ${PROJ_SOURCE_DIR}/cmake/ProjReadme.cmake
)
get_property(_is_multi_config_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT _is_multi_config_generator)
add_custom_target(dist
COMMAND ${CMAKE_MAKE_PROGRAM} package_source
DEPENDS README
)
message(STATUS "PROJ: Configured 'dist' target")
endif()
configure_file(cmake/uninstall.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/proj_uninstall.cmake @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/proj_uninstall.cmake)