-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
450 lines (370 loc) · 13.8 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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
###############################################################################
#
# CMake main configuration file to build GeoTIFF library and utilities.
#
# Author: Mateusz Loskot <[email protected]>
#
###############################################################################
PROJECT(GeoTIFF)
SET(GEOTIFF_LIB_NAME geotiff)
SET(GEOTIFF_LIBRARY_TARGET geotiff_library)
SET(GEOTIFF_ARCHIVE_TARGET geotiff_archive)
##############################################################################
# CMake settings
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
SET(CMAKE_COLOR_MAKEFILE ON)
# Allow advanced users to generate Makefiles printing detailed commands
MARK_AS_ADVANCED(CMAKE_VERBOSE_MAKEFILE)
# Path to additional CMake modules
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
###############################################################################
###
# Set up the version and configure a header file with the version in it.
###
set (GeoTIFF_VERSION_MAJOR 2)
set (GeoTIFF_VERSION_MINOR 1)
set (GeoTIFF_VERSION_RELEASE 0)
set (GeoTIFF_VERSION ${GeoTIFF_VERSION_MAJOR}.${GeoTIFF_VERSION_MINOR}.${GeoTIFF_VERSION_RELEASE})
###
# Currently commented out. Could add build data and svn revision in here:
# configure_file ( "${PROJECT_SOURCE_DIR}/geotiff_version.h.in"
# "${PROJECT_BINARY_DIR}/geotiff_version.h" )
###
# General build settings
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel"
FORCE)
ENDIF()
SET(GEOTIFF_BUILD_PEDANTIC FALSE CACHE BOOL "Choose compilation in pedantic or relaxed mode")
IF(CMAKE_BUILD_TYPE MATCHES Debug)
SET(GEOTIFF_BUILD_PEDANTIC TRUE)
ENDIF()
# TODO: Still testing the output paths --mloskot
SET(GEOTIFF_BUILD_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# Output directory in which to build RUNTIME target files.
# SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${GEOTIFF_BUILD_OUTPUT_DIRECTORY})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# Output directory in which to build LIBRARY target files
# SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${GEOTIFF_BUILD_OUTPUT_DIRECTORY})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
# Output directory in which to build ARCHIVE target files.
# SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${GEOTIFF_BUILD_OUTPUT_DIRECTORY})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
###############################################################################
# Platform and compiler specific settings
IF(WIN32)
IF(MSVC)
ADD_DEFINITIONS(-DBUILD_AS_DLL=1)
ADD_DEFINITIONS(/DW4)
IF(MSVC80)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNING)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ENDIF()
ENDIF(MSVC)
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
SET(COMPILE_FLAGS "-fPIC -Wall -Wno-long-long")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILE_FLAGS} -std=c99")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS} -std=c++98")
IF(GEOTIFF_BUILD_PEDANTIC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
ENDIF()
ENDIF()
# Check required standard headers
INCLUDE(CheckIncludeFiles)
CHECK_INCLUDE_FILES(stdio.h HAVE_STDIO_H)
CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H)
CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
###############################################################################
# User-defined build settings
SET(GEOTIFF_CSV_NAMES area.csv codes.csv datum.csv gcs.csv pcs.csv)
FIND_PATH(GEOTIFF_CSV_DATA_DIR NAMES ${GEOTIFF_CSV_NAMES}
PATHS "${CMAKE_SOURCE_DIR}/csv"
DOC "Default location of GeoTIFF CSV files"
NO_DEFAULT_PATH)
IF(IS_DIRECTORY ${GEOTIFF_CSV_DATA_DIR} AND EXISTS "${GEOTIFF_CSV_DATA_DIR}/gcs.csv")
MESSAGE(STATUS "Found GeoTIFF CSV files in: ${GEOTIFF_CSV_DATA_DIR}")
ADD_DEFINITIONS(-DCSV_DATA_DIR="${GEOTIFF_CSV_DATA_DIR}")
ELSE()
MESSAGE(FATAL_ERROR "Failed to find GeoTIFF CSV files in: ${GEOTIFF_CSV_DATA_DIR}")
ENDIF()
# Has the user requested "incode" EPSG tables, overriding the default
# use of EPSG tables in csv files?
SET(GEOTIFF_ENABLE_INCODE_EPSG FALSE CACHE BOOL
"Choose if C code EPSG tables should be used")
MESSAGE(STATUS "Enable in-code GeoTIFF EPSG tables: ${GEOTIFF_ENABLE_INCODE_EPSG}")
SET(WITH_UTILITIES TRUE CACHE BOOL "Choose if GeoTIFF utilities should be built")
###############################################################################
# Search for dependencies
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libxtiff)
# TIFF support - required, default=ON
SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built")
IF(WITH_TIFF)
FIND_PACKAGE(TIFF REQUIRED)
IF(TIFF_FOUND)
# Confirm required API is available
INCLUDE(CheckFunctionExists)
SET(CMAKE_REQUIRED_LIBRARIES ${TIFF_LIBRARIES})
CHECK_FUNCTION_EXISTS(TIFFOpen HAVE_TIFFOPEN)
IF(NOT HAVE_TIFFOPEN)
SET(TIFF_FOUND) # ReSET to NOT found for TIFF library
MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFOpen function not found")
ENDIF()
CHECK_FUNCTION_EXISTS(TIFFMergeFieldInfo HAVE_TIFFMERGEFIELDINFO)
IF(NOT HAVE_TIFFMERGEFIELDINFO)
SET(TIFF_FOUND) # ReSET to NOT found for TIFF library
MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFMergeFieldInfo function not found. libtiff 3.6.0 Beta or later required. Please upgrade or use an older version of libgeotiff")
ENDIF()
INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR})
ADD_DEFINITIONS(-DHAVE_TIFF=1)
ENDIF(TIFF_FOUND)
ENDIF(WITH_TIFF)
# PROJ.4 support - optional, default=ON
SET(WITH_PROJ4 TRUE CACHE BOOL "Choose if PROJ.4 support should be built")
IF(WITH_PROJ4)
FIND_PACKAGE(PROJ4)
IF(PROJ4_FOUND)
ADD_DEFINITIONS(-DHAVE_LIBPROJ=1)
INCLUDE_DIRECTORIES(${PROJ4_INCLUDE_DIR})
IF(EXISTS "${PROJ4_INCLUDE_DIR}/projects.h")
MESSAGE(STATUS "Looking for projects.h header from PROJ.4 library - found")
ADD_DEFINITIONS(-DHAVE_PROJECTS_H=1)
INCLUDE_DIRECTORIES(${PROJ4_INCLUDE_DIR_2})
ELSE()
MESSAGE(FATAL_ERROR "Looking for projects.h from PROJ.4 library - not found")
ENDIF()
ENDIF()
ENDIF()
# Zlib support - optional, default=OFF
SET(WITH_ZLIB FALSE CACHE BOOL "Choose if zlib support should be built")
IF(WITH_ZLIB)
FIND_PACKAGE(ZLIB)
IF(ZLIB_FOUND)
SET(HAVE_ZIP 1)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
ADD_DEFINITIONS(-DHAVE_ZIP=${HAVE_ZIP})
ENDIF()
ENDIF()
# JPEG support - optional, default=OFF
SET(WITH_JPEG FALSE CACHE BOOL "Choose if JPEG support should be built")
IF(WITH_JPEG)
FIND_PACKAGE(JPEG)
IF(JPEG_FOUND)
SET(HAVE_JPEG 1)
INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR})
ADD_DEFINITIONS(-DHAVE_JPEG=${HAVE_JPEG})
ENDIF()
ENDIF()
###############################################################################
# Generate geo_config.h with compile-time configuration
MESSAGE(STATUS "Generating geo_config.h header")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/geo_config.h.in
${CMAKE_CURRENT_SOURCE_DIR}/geo_config.h)
MESSAGE(STATUS "Generating geo_config.h header - done")
###############################################################################
# Installation settings
SET(GEOTIFF_CSV_DATA
csv/alias.csv
csv/area.csv
csv/change.csv
csv/compdcs.csv
csv/coordinate_axis.csv
csv/coordinate_axis_name.csv
csv/coordinate_operation.csv
csv/coordinate_operation_method.csv
csv/coordinate_operation_parameter.csv
csv/coordinate_operation_parameter_value.csv
csv/coordinate_operation_path.csv
csv/coordinate_reference_system.csv
csv/coordinate_system.csv
csv/datum.csv
csv/datum_shift.csv
csv/datum_shift_pref.csv
csv/deprecation.csv
csv/ellipsoid.csv
csv/esri_datum_override.csv
csv/gcs.csv
csv/gcs.override.csv
csv/geoccs.csv
csv/naming_system.csv
csv/pcs.csv
csv/pcs.override.csv
csv/prime_meridian.csv
csv/projop_wparm.csv
csv/stateplane.csv
csv/supersession.csv
csv/unit_of_measure.csv
csv/version_history.csv
csv/vertcs.csv
csv/vertcs.override.csv )
SET(GEOTIFF_LIB_HEADERS
geotiff.h
geotiffio.h
geovalues.h
geonames.h
geokeys.h
geo_config.h
geo_tiffp.h
geo_keyp.h
geo_normalize.h
cpl_serv.h
geo_simpletags.h
epsg_datum.inc
epsg_gcs.inc
epsg_pm.inc
epsg_units.inc
geo_ctrans.inc
epsg_ellipse.inc
epsg_pcs.inc
epsg_proj.inc
epsg_vertcs.inc
geokeys.inc
libxtiff/xtiffio.h)
# ${PROJECT_BINARY_DIR}/geotiff_version.h
IF(WIN32)
SET(DEFAULT_LIB_SUBDIR lib)
SET(DEFAULT_DATA_SUBDIR .)
SET(DEFAULT_INCLUDE_SUBDIR include)
IF(MSVC)
SET(DEFAULT_BIN_SUBDIR bin)
ELSE()
SET(DEFAULT_BIN_SUBDIR .)
ENDIF()
ELSE()
# Common locatoins for Unix and Mac OS X
SET(DEFAULT_BIN_SUBDIR bin)
SET(DEFAULT_LIB_SUBDIR lib)
SET(DEFAULT_DATA_SUBDIR share)
SET(DEFAULT_INCLUDE_SUBDIR include)
ENDIF()
# Locations are changeable by user to customize layout of GeoTIFF installation
# (default values are platform-specIFic)
SET(GEOTIFF_BIN_SUBDIR ${DEFAULT_BIN_SUBDIR} CACHE STRING
"Subdirectory where executables will be installed")
SET(GEOTIFF_LIB_SUBDIR ${DEFAULT_LIB_SUBDIR} CACHE STRING
"Subdirectory where libraries will be installed")
SET(GEOTIFF_INCLUDE_SUBDIR ${DEFAULT_INCLUDE_SUBDIR} CACHE STRING
"Subdirectory where header files will be installed")
SET(GEOTIFF_DATA_SUBDIR ${DEFAULT_DATA_SUBDIR} CACHE STRING
"Subdirectory where data will be installed")
# Mark *_SUBDIR variables as advanced and dedicated to use by power-users only.
MARK_AS_ADVANCED(GEOTIFF_BIN_SUBDIR GEOTIFF_LIB_SUBDIR GEOTIFF_INCLUDE_SUBDIR GEOTIFF_DATA_SUBDIR)
# Full paths for the installation
SET(GEOTIFF_BIN_DIR ${GEOTIFF_BIN_SUBDIR})
SET(GEOTIFF_LIB_DIR ${GEOTIFF_LIB_SUBDIR})
SET(GEOTIFF_INCLUDE_DIR ${GEOTIFF_INCLUDE_SUBDIR})
SET(GEOTIFF_DATA_DIR ${GEOTIFF_DATA_SUBDIR})
# Install doc files
INSTALL(FILES
AUTHORS ChangeLog COPYING INSTALL LICENSE README README_BIN README.WIN
DESTINATION doc)
# DESTINATION ${GEOTIFF_DATA_DIR}/doc)
# Install CSV data files
# INSTALL(FILES ${GEOTIFF_CSV_DATA} DESTINATION ${GEOTIFF_DATA_DIR}/epsg_csv)
INSTALL(FILES ${GEOTIFF_CSV_DATA} DESTINATION share/epsg_csv)
# Install header files for development distribution
# INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION ${GEOTIFF_INCLUDE_DIR})
INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION include)
###############################################################################
# Build libxtiff library
ADD_SUBDIRECTORY(libxtiff)
###############################################################################
# Build libgeotiff library
SET(GEOTIFF_LIB_SOURCES
cpl_serv.c
cpl_csv.c
geo_extra.c
geo_free.c
geo_get.c
geo_names.c
geo_new.c
geo_normalize.c
geo_print.c
geo_set.c
geo_simpletags.c
geo_tiffp.c
geo_trans.c
geo_write.c
geotiff_proj4.c)
IF (GEOTIFF_ENABLE_INCODE_EPSG)
SET(GEOTIFF_LIB_CSV_SOURCES
csv/datum.c
csv/ellipsoid.c
csv/gcs.c
csv/pcs.c
csv/prime_meridian.c
csv/projop_wparm.c
csv/unit_of_measure.c)
SOURCE_GROUP("CSV Source Files" FILES ${GEOTIFF_LIB_CSV_SOURCES})
ENDIF(GEOTIFF_ENABLE_INCODE_EPSG)
SET(XTIFF_SOURCES libxtiff/xtiff.c)
#---
# Static libgeotiff archive
# NOTE: Did not put XTIFF_SOURCES in static lib because libxtiff.a is written out
# currently.
#---
ADD_LIBRARY(${GEOTIFF_ARCHIVE_TARGET} STATIC
${GEOTIFF_LIB_SOURCES} ${GEOTIFF_LIB_CSV_SOURCES})
SET_TARGET_PROPERTIES(${GEOTIFF_ARCHIVE_TARGET} PROPERTIES
OUTPUT_NAME ${GEOTIFF_LIB_NAME})
# Shared libgeotiff library
ADD_LIBRARY(${GEOTIFF_LIBRARY_TARGET} SHARED
${GEOTIFF_LIB_SOURCES} ${GEOTIFF_LIB_CSV_SOURCES} ${XTIFF_SOURCES})
# Windows:
IF(WIN32 AND MSVC)
SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES IMPORT_SUFFIX "_i.lib")
ENDIF(WIN32 AND MSVC)
# Unix, linux:
IF(UNIX)
IF(NOT LINK_SOVERSION)
set(LINK_SOVERSION "${GeoTIFF_VERSION_MAJOR}")
ENDIF(NOT LINK_SOVERSION)
IF(NOT LINK_VERSION)
set(LINK_VERSION "${GeoTIFF_VERSION}")
ENDIF(NOT LINK_VERSION)
SET_TARGET_PROPERTIES(
${GEOTIFF_LIBRARY_TARGET}
PROPERTIES
OUTPUT_NAME ${GEOTIFF_LIB_NAME}
VERSION ${LINK_VERSION}
SOVERSION ${LINK_SOVERSION}
CLEAN_DIRECT_OUTPUT 1 )
if (APPLE)
set_target_properties(
${GEOTIFF_LIBRARY_TARGET}
PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif()
ELSE(UNIX)
# Default:
SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES
OUTPUT_NAME ${GEOTIFF_LIB_NAME})
ENDIF(UNIX)
SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES
OUTPUT_NAME ${GEOTIFF_LIB_NAME})
TARGET_LINK_LIBRARIES(${GEOTIFF_LIBRARY_TARGET}
${TIFF_LIBRARIES}
${PROJ4_LIBRARIES}
${ZLIB_LIBRARIES}
${JPEG_LIBRARIES})
# INSTALL(TARGETS ${GEOTIFF_ARCHIVE_TARGET} ${GEOTIFF_LIBRARY_TARGET}
# RUNTIME DESTINATION ${GEOTIFF_BIN_DIR}
# LIBRARY DESTINATION ${GEOTIFF_LIB_DIR}
# ARCHIVE DESTINATION ${GEOTIFF_LIB_DIR})
INSTALL( TARGETS ${GEOTIFF_ARCHIVE_TARGET} ${GEOTIFF_LIBRARY_TARGET}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib )
# Define grouping of source files in PROJECT file (e.g. Visual Studio)
SOURCE_GROUP("CMake Files" FILES CMakeLists.txt)
SOURCE_GROUP("Header Files" FILES ${GEOTIFF_LIB_HEADERS})
SOURCE_GROUP("Source Files" FILES ${GEOTIFF_LIB_SOURCES})
###############################################################################
# Build GeoTIFF utilities
IF(WITH_UTILITIES)
ADD_SUBDIRECTORY(bin)
ENDIF()