forked from libLAS/libLAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
404 lines (326 loc) · 12.4 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
###############################################################################
# Main CMake configuration file for libLAS
#
# Author: Mateusz Loskot <[email protected]>
#
#
###############################################################################
cmake_minimum_required(VERSION 2.8.11)
# libLAS general settings
project(libLAS)
SET(LIBLAS_VERSION_MAJOR "1")
SET(LIBLAS_VERSION_MINOR "8")
SET(LIBLAS_VERSION_PATCH "2b1")
set(VERSION "${LIBLAS_VERSION_MAJOR}.${LIBLAS_VERSION_MINOR}.${LIBLAS_VERSION_PATCH}")
SET(LIBLAS_LIB_VERSION "2.4.0")
SET(LIBLAS_LIB_SOVERSION "3")
SET(LIBLAS_C_LIB_VERSION "2.4.0")
SET(LIBLAS_C_LIB_SOVERSION "3")
SET(OSGEO4W_UPSTREAM_RELEASE "1")
if(WIN32)
# Name of C++ library
set(LIBLAS_LIB_NAME liblas)
# Name of C library
set(LIBLAS_C_LIB_NAME liblas_c)
else()
# Name of C++ library
set(LIBLAS_LIB_NAME las)
# Name of C library
set(LIBLAS_C_LIB_NAME las_c)
endif()
# Name of test suite runner
set(LIBLAS_UNIT_TEST liblas_test)
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
# Choose package components
set(WITH_UTILITIES TRUE CACHE BOOL "Choose if libLAS utilities should be built")
set(WITH_TESTS TRUE CACHE BOOL "Choose if libLAS unit tests should be built")
set(BUILD_OSGEO4W TRUE CACHE BOOL "Should OSGeo4W package for Windows be built")
# Choose to use pkg-config or not
if (UNIX OR MINGW)
set(DEFAULT_WITH_PKGCONFIG TRUE)
else()
set(DEFAULT_WITH_PKGCONFIG FALSE)
endif()
set(WITH_PKGCONFIG ${DEFAULT_WITH_PKGCONFIG} CACHE BOOL
"Choose whether a pkgconfig file (libLAS.pc) should be installed")
set(WITH_ENDIANAWARE FALSE CACHE BOOL "Choose whether or not libLAS should do runtime endianness switching. Note that this can slow things down considerably if enabled by default")
###############################################################################
# CMake settings
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 "${libLAS_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
###############################################################################
# General build settings
# Default to debug mode until final 1.6.0 release
if(NOT MSVC_IDE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel" FORCE)
endif()
message(STATUS "Setting libLAS build type - ${CMAKE_BUILD_TYPE}")
endif()
# TODO: Still testing the output paths --mloskot
set(LIBLAS_BUILD_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}")
# Output directory in which to build RUNTIME target files.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBLAS_BUILD_OUTPUT_DIRECTORY})
# Output directory in which to build LIBRARY target files
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBLAS_BUILD_OUTPUT_DIRECTORY})
# Output directory in which to build ARCHIVE target files.
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBLAS_BUILD_OUTPUT_DIRECTORY})
file(READ "doc/index.txt" README )
file(WRITE "README.txt" "${README}")
###############################################################################
# Platform and compiler specific settings
if(WIN32)
if (MSVC)
if (MSVC80 OR MSVC90 OR MSVC10 OR MSVC11 OR MSVC12)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNING)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif()
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4"
CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
# Generate dot-user file with user-specific settings for
# Visual Studio project
set(MSVC_ENVIRONMENT_PATH "" CACHE STRING
"Custom PATH for Environment property in Visual Studio for project")
mark_as_advanced(MSVC_ENVIRONMENT_PATH)
set(VCPROJ_USER_ENVIRONMENT_PATH_DEBUG "${ENVIRONMENT_PATH}")
mark_as_advanced(VCPROJ_USER_ENVIRONMENT_PATH_DEBUG)
endif()
set(CMAKE_INCLUDE_PATH c:/osgeo4w64/include;$ENV{CMAKE_INCLUDE_PATH})
set(CMAKE_LIBRARY_PATH c:/osgeo4w64/lib;$ENV{CMAKE_LIBRARY_PATH})
else()
# Recommended C++ compilation flags
# -Weffc++
#
# Remove -pedandic which causes errors from boost (comma at end of
# enum) 2012-09-05. Remove -Wcast-qual -Wfloat-equal
# -Wredundant-decls to suppress the multitude of warning messages.
set(LIBLAS_COMMON_CXX_FLAGS
" -Wextra -Wall -Wno-unused-parameter -Wno-unused-variable -Wpointer-arith -Wcast-align -Wcast-qual -Wfloat-equal -Wredundant-decls -Wno-long-long")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBLAS_COMMON_CXX_FLAGS}")
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -ansi")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER}" MATCHES "clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBLAS_COMMON_CXX_FLAGS}")
endif()
endif(WIN32)
if (APPLE)
set(SO_EXT dylib)
set(CMAKE_FIND_FRAMEWORK "LAST")
elseif(WIN32)
set(SO_EXT dll)
else()
set(SO_EXT so)
endif(APPLE)
###############################################################################
# Search for dependencies
# Boost C++ Libraries support - required
message(STATUS "Searching for Boost 1.38+ - done")
# Default to using static, multithreaded libraries for
# linking under MSVC. This is because we show users how to
# use boostpro.com installer and install those options when linking
# on windows in the compilation documentation.
if(WIN32)
if (MSVC)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
endif(MSVC)
endif(WIN32)
find_package(Threads)
find_package(Boost 1.42 COMPONENTS program_options thread system iostreams filesystem REQUIRED)
if(Boost_FOUND AND Boost_PROGRAM_OPTIONS_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif()
# make these available for the user to set.
mark_as_advanced(CLEAR Boost_INCLUDE_DIR)
mark_as_advanced(CLEAR Boost_LIBRARY_DIRS)
link_directories(${Boost_LIBRARY_DIRS})
# LASZIP support - optional, default=ON
set(WITH_LASZIP FALSE CACHE BOOL "Choose if LASzip support should be built")
set(WITH_STATIC_LASZIP FALSE CACHE BOOL "Choose of LASzip should be statically linked")
mark_as_advanced(WITH_STATIC_LASZIP)
if (WITH_LASZIP)
find_package (LASzip 2.0.1 QUIET NO_MODULE)
if (NOT LASZIP_FOUND)
find_package (LASzip 2.0.1)
endif ()
endif ()
if(LASZIP_FOUND)
include_directories(${LASZIP_INCLUDE_DIR})
add_definitions(-DHAVE_LASZIP=1)
mark_as_advanced(CLEAR LASZIP_INCLUDE_DIR)
mark_as_advanced(CLEAR LASZIP_LIBRARY)
mark_as_advanced(CLEAR LASZIP_VERSION)
set(WITH_LASZIP TRUE)
else()
set(LASZIP_LIBRARY "")
set(LASZIP_INCLUDE_DIR "")
endif()
# GDAL/OGR support - optional, default=OFF
set(WITH_GDAL FALSE CACHE BOOL "Choose if GDAL support should be built")
if (WITH_GDAL)
find_package (GDAL 1.7.0 NO_MODULE QUIET)
if (NOT GDAL_FOUND)
find_package (GDAL 1.7.0)
endif ()
endif ()
if (GDAL_FOUND)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)
include_directories(${GDAL_INCLUDE_DIR})
add_definitions(-DHAVE_GDAL=1)
set(WITH_GDAL TRUE)
mark_as_advanced(CLEAR GDAL_INCLUDE_DIR)
mark_as_advanced(CLEAR GDAL_LIBRARY)
find_package (PROJ4 NO_MODULE QUIET)
if (NOT PROJ4_FOUND)
find_package (PROJ4)
endif ()
endif()
# GeoTIFF support - required, default=ON
set(WITH_GEOTIFF TRUE CACHE BOOL "Choose if GeoTIFF support should be built")
if(WITH_GEOTIFF)
find_package (GeoTIFF 1.3.0 )
if(GEOTIFF_FOUND)
set(WITH_GEOTIFF TRUE)
# Confirm required API is available
include(CheckFunctionExists)
include_directories(${GEOTIFF_INCLUDE_DIR})
add_definitions(-DHAVE_LIBGEOTIFF=1)
# geotiff probably depends on proj, so we need those libs to avoid linker errors
find_package(PROJ)
mark_as_advanced(CLEAR TIFF_INCLUDE_DIR)
mark_as_advanced(CLEAR TIFF_LIBRARY)
if (WIN32)
set(TIFF_NAMES libtiff_i)
endif(WIN32)
find_package (TIFF QUIET NO_MODULE)
if (NOT TIFF_FOUND)
find_package(TIFF)
endif ()
if (TIFF_FOUND)
include_directories(${TIFF_INCLUDE_DIR})
endif()
find_package (JPEG NO_MODULE QUIET)
if (NOT JPEG_FOUND)
find_package (JPEG)
endif ()
find_package (ZLIB NO_MODULE QUIET)
if (NOT ZLIB_FOUND)
find_package (ZLIB)
endif ()
else()
message(FATAL_ERROR "Unable to find sufficient GeoTIFF")
endif()
else()
set(GEOTIFF_LIBRARY "")
endif()
if(WITH_GDAL)
if (NOT GEOTIFF_FOUND)
message(FATAL_ERROR
"GDAL support requires GeoTIFF library which was not found")
endif()
endif()
if(WITH_ENDIANAWARE)
add_definitions(-DLIBLAS_ENDIAN_AWARE=1)
endif()
###############################################################################
# Installation settings
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/liblas)
set(DEFAULT_INCLUDE_SUBDIR include)
endif()
# Locations are changeable by user to customize layout of libLAS installation
# (default values are platform-specific)
set(LIBLAS_BIN_SUBDIR ${DEFAULT_BIN_SUBDIR} CACHE STRING
"Subdirectory where executables will be installed")
set(LIBLAS_LIB_SUBDIR ${DEFAULT_LIB_SUBDIR} CACHE STRING
"Subdirectory where libraries will be installed")
set(LIBLAS_INCLUDE_SUBDIR ${DEFAULT_INCLUDE_SUBDIR} CACHE STRING
"Subdirectory where header files will be installed")
set(LIBLAS_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(LIBLAS_BIN_SUBDIR
LIBLAS_LIB_SUBDIR LIBLAS_INCLUDE_SUBDIR LIBLAS_DATA_SUBDIR)
# Full paths for the installation
set(LIBLAS_BIN_DIR ${LIBLAS_BIN_SUBDIR})
set(LIBLAS_LIB_DIR ${LIBLAS_LIB_SUBDIR})
set(LIBLAS_INCLUDE_DIR ${LIBLAS_INCLUDE_SUBDIR})
set(LIBLAS_DATA_DIR ${LIBLAS_DATA_SUBDIR})
###############################################################################
# Installation commands
install(FILES AUTHORS INSTALL LICENSE.txt README.txt
DESTINATION ${LIBLAS_DATA_DIR}/doc)
###############################################################################
# Processing of project directories
add_subdirectory(src)
if(WITH_UTILITIES)
message(STATUS "Enable libLAS utilities to build - done")
add_subdirectory(apps)
endif()
if(WITH_TESTS)
message(STATUS "Enable libLAS unit tests to build - done")
enable_testing()
add_subdirectory(test)
endif()
# Add find_package(libLAS) support
add_subdirectory(cmake)
# Version information
SET(CPACK_PACKAGE_VERSION_MAJOR ${LIBLAS_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${LIBLAS_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${LIBLAS_VERSION_MINOR})
SET(CPACK_SOURCE_GENERATOR "TBZ2")
SET(CPACK_CMAKE_GENERATOR "Unix Makefiles")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${VERSION}")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/test/data/TO_core_last_zoom.las")
list(APPEND CPACK_SOURCE_IGNORE_FILES "_CPack_Packages")
list(APPEND CPACK_SOURCE_IGNORE_FILES ".gz")
list(APPEND CPACK_SOURCE_IGNORE_FILES ".bz2")
list(APPEND CPACK_SOURCE_IGNORE_FILES ".git")
list(APPEND CPACK_SOURCE_IGNORE_FILES "README")
list(APPEND CPACK_SOURCE_IGNORE_FILES "HOWTORELEASE.txt")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/doc/_static/files")
list(APPEND CPACK_SOURCE_IGNORE_FILES "CMakeCache.txt")
list(APPEND CPACK_SOURCE_IGNORE_FILES "CMakeFiles")
file(GLOB DISTS "libLAS*")
list(APPEND CPACK_SOURCE_IGNORE_FILES ${DISTS})
list(APPEND CPACK_SOURCE_IGNORE_FILES "Makefile")
list(APPEND CPACK_SOURCE_IGNORE_FILES "cmake_install.cmake")
list(APPEND CPACK_SOURCE_IGNORE_FILES "CPackConfig.cmake")
list(APPEND CPACK_SOURCE_IGNORE_FILES "CPackSourceConfig.cmake")
list(APPEND CPACK_SOURCE_IGNORE_FILES "CTestTestfile.cmake")
list(APPEND CPACK_SOURCE_IGNORE_FILES "schemas")
list(APPEND CPACK_SOURCE_IGNORE_FILES "liblas-osgeo4w-init.bat")
list(APPEND CPACK_SOURCE_IGNORE_FILES "liblas-osgeo4w-start.bat.tmpl")
list(APPEND CPACK_SOURCE_IGNORE_FILES "liblas-osgeo4w-postinstall.bat")
include(CPack)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
if (WIN32 AND BUILD_OSGEO4W)
include(BuildOSGeo4W)
endif ()