forked from PDAL/PDAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
413 lines (355 loc) · 12.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
404
405
406
407
408
409
410
411
412
413
#
# top-level CMake configuration file for PDAL
#
# (based originally on the libLAS files copyright Mateusz Loskot)
cmake_minimum_required(VERSION 3.13)
project(PDAL VERSION 2.7.0 LANGUAGES CXX C)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
set(ROOT_DIR "${PROJECT_SOURCE_DIR}")
include(${ROOT_DIR}/cmake/common.cmake NO_POLICY_SCOPE)
#------------------------------------------------------------------------------
# internal cmake settings
#------------------------------------------------------------------------------
set(CMAKE_COLOR_MAKEFILE ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
include(FeatureSummary)
# Allow advanced users to generate Makefiles printing detailed commands
mark_as_advanced(CMAKE_VERBOSE_MAKEFILE)
#------------------------------------------------------------------------------
# PDAL general settings
#------------------------------------------------------------------------------
#
# Must be changed if there is an ABI change. This builds the SONAME
# that's embedded in the library and any plugins.
include(${ROOT_DIR}/cmake/libraries.cmake NO_POLICY_SCOPE)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
#
# Name of C++ library
#
set(PDAL_LIB_NAME pdalcpp)
set(PDAL_KAZHDAN_LIB_NAME pdal_kazhdan)
set(PDAL_LEPCC_LIB_NAME pdal_lepcc)
set(PDAL_TEST_SUPPORT_OBJS pdal_test_support)
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
set(PDAL_OUTPUT_LIB_DIR "${PROJECT_BINARY_DIR}/lib")
set(PDAL_OUTPUT_BIN_DIR "${PROJECT_BINARY_DIR}/bin")
if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PDAL_OUTPUT_LIB_DIR}")
endif()
if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PDAL_OUTPUT_BIN_DIR}")
endif()
# allow override of PDAL_PLUGIN_INSTALL_PATH path
if (NOT PDAL_PLUGIN_INSTALL_PATH)
if (WIN32)
set(PDAL_PLUGIN_INSTALL_PATH "${CMAKE_INSTALL_BINDIR}" CACHE PATH "PDAL Plugin install location")
else()
set(PDAL_PLUGIN_INSTALL_PATH "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "PDAL Plugin install location")
endif()
endif()
include(${PDAL_CMAKE_DIR}/rpath.cmake)
# wipe lib/ drectory on clean. It will have plugins that could be out of date
# in the next build
set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${PDAL_OUTPUT_LIB_DIR}/*")
if(WIN32)
add_definitions("-DPDAL_DLL_EXPORT=1")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE} "${PDAL_OUTPUT_LIB_DIR}" )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE} "${PDAL_OUTPUT_BIN_DIR}" )
# ---[ Windows requires DLLs (shared libraries) to be installed in
# ---[ the same directory as executables
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE} "${PDAL_OUTPUT_BIN_DIR}" )
endif(WIN32)
# Choose package components
include(${PDAL_CMAKE_DIR}/options.cmake)
#------------------------------------------------------------------------------
# General build settings
#------------------------------------------------------------------------------
set(PDAL_BUILD_TYPE ${CMAKE_BUILD_TYPE})
#------------------------------------------------------------------------------
# Dependencies.
#------------------------------------------------------------------------------
include(${PDAL_CMAKE_DIR}/backtrace.cmake)
include(${PDAL_CMAKE_DIR}/proj.cmake)
include(${PDAL_CMAKE_DIR}/gdal.cmake)
include(${PDAL_CMAKE_DIR}/geotiff.cmake) # Optional (not really)
include(${PDAL_CMAKE_DIR}/threads.cmake)
include(${PDAL_CMAKE_DIR}/zlib.cmake)
include(${PDAL_CMAKE_DIR}/lzma.cmake)
include(${PDAL_CMAKE_DIR}/zstd.cmake)
include(${PDAL_CMAKE_DIR}/test.cmake)
include(${PDAL_CMAKE_DIR}/ctest.cmake)
include(${PDAL_CMAKE_DIR}/libxml2.cmake)
include(${PDAL_CMAKE_DIR}/dimension.cmake)
include(${PDAL_CMAKE_DIR}/arbiter.cmake)
include(${PDAL_CMAKE_DIR}/h3.cmake)
include(${PDAL_CMAKE_DIR}/nlohmann.cmake)
include(${PDAL_CMAKE_DIR}/schema-validator.cmake)
include(${PDAL_CMAKE_DIR}/lazperf.cmake)
include(${PDAL_CMAKE_DIR}/gcs.cmake) # Optional
include(${PDAL_CMAKE_DIR}/utfcpp.cmake)
#------------------------------------------------------------------------------
# generate the pdal_features.hpp header
#------------------------------------------------------------------------------
# from http://stackoverflow.com/questions/1435953/how-can-i-pass-git-sha1-to-compiler-as-definition-using-cmake
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
# needs to come before configuration of pdal_features
if(APPLE)
option(PDAL_BUNDLE "Create PDAL as Application Bundle on OSX" FALSE)
if (PDAL_BUNDLE)
set(PDAL_APP_BUNDLE 1)
endif()
endif()
set(pdal_features_hpp_in "${CMAKE_CURRENT_SOURCE_DIR}/pdal_features.hpp.in")
set(pdal_features_hpp
"${CMAKE_CURRENT_BINARY_DIR}/include/pdal/pdal_features.hpp")
configure_file(${pdal_features_hpp_in} ${pdal_features_hpp})
#------------------------------------------------------------------------------
# subdirectory controls
#------------------------------------------------------------------------------
# PDAL_TARGET_OBJECTS is used to collect the driver object libraries
set(PDAL_TARGET_OBJECTS "")
if (WITH_TESTS)
enable_testing()
endif()
add_subdirectory(plugins)
if (WITH_TESTS)
include (${PDAL_CMAKE_DIR}/gtest.cmake)
add_subdirectory(test)
endif()
add_subdirectory(dimbuilder)
add_subdirectory(vendor/arbiter)
add_subdirectory(vendor/schema-validator)
add_subdirectory(vendor/kazhdan)
add_subdirectory(vendor/lazperf)
add_subdirectory(vendor/utfcpp)
add_subdirectory(vendor/lepcc)
add_subdirectory(vendor/h3)
add_subdirectory(tools)
add_subdirectory(apps)
file(GLOB BASE_SRCS
${PDAL_FILTERS_DIR}/*.cpp
${PDAL_IO_DIR}/*.cpp
${PDAL_KERNELS_DIR}/*.cpp
${PDAL_SRC_DIR}/*.cpp
${PDAL_SRC_DIR}/compression/*.cpp
${PDAL_SRC_DIR}/util/*.cpp)
file(GLOB_RECURSE PRIVATE_SRCS
${PDAL_FILTERS_DIR}/private/*.cpp
${PDAL_IO_DIR}/private/*.cpp
${PDAL_KERNELS_DIR}/private/*.cpp
${PDAL_SRC_DIR}/private/*.cpp
${BACKTRACE_SOURCE})
list(APPEND SRCS ${BASE_SRCS} ${PRIVATE_SRCS})
#
# Remove stuff we don't want to build.
#
if (NOT PDAL_HAVE_LIBXML2)
file(GLOB XML_SRCS
io/Ilvis2MetadataReader.cpp
io/Ilvis2Metadata.cpp
io/Ilvis2Reader.cpp
${PDAL_SRC_DIR}/DbWriter.cpp
${PDAL_SRC_DIR}/DbReader.cpp
${PDAL_SRC_DIR}/XMLSchema.cpp)
list(REMOVE_ITEM SRCS ${XML_SRCS})
endif()
if (NOT PDAL_HAVE_ZSTD)
file(GLOB ZSTD_SRCS
${PDAL_SRC_DIR}/compression/ZstdCompression.cpp)
list(REMOVE_ITEM SRCS ${ZSTD_SRCS})
endif()
if (NOT PDAL_HAVE_ZLIB)
file(GLOB ZLIB_SRCS
${PDAL_SRC_DIR}/compression/DeflateCompression.cpp)
list(REMOVE_ITEM SRCS ${ZLIB_SRCS})
endif()
if (NOT PDAL_HAVE_LZMA)
file(GLOB LZMA_SRCS
${PDAL_SRC_DIR}/compression/LzmaCompression.cpp)
list(REMOVE_ITEM SRCS ${LZMA_SRCS})
endif()
PDAL_ADD_LIBRARY(${PDAL_LIB_NAME} ${SRCS})
add_library(PDAL::PDAL ALIAS ${PDAL_LIB_NAME})
#
# Interface include directories allow downstream project to get the directory
# without specification.
#
target_include_directories(${PDAL_LIB_NAME}
SYSTEM BEFORE PRIVATE
${PDAL_VENDOR_DIR}/eigen
${PDAL_VENDOR_DIR}/kazhdan
${PDAL_VENDOR_DIR}/h3/include
)
target_include_directories(${PDAL_LIB_NAME}
PRIVATE
${ROOT_DIR}
${PROJECT_BINARY_DIR}/include
${PDAL_VENDOR_DIR}
${LIBXML2_INCLUDE_DIR}
${ZSTD_INCLUDE_DIRS}
${NLOHMANN_INCLUDE_DIR}
${UTFCPP_INCLUDE_DIR}
${GDAL_INCLUDE_DIR}
${PROJ_INCLUDE_DIR}
)
target_link_libraries(${PDAL_LIB_NAME}
PRIVATE
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
${GDAL_LIBRARY}
${PROJ_LIBRARIES}
${GEOTIFF_LIBRARY}
${LIBXML2_LIBRARIES}
${ZLIB_LIBRARIES}
${LIBLZMA_LIBRARIES}
${ZSTD_LIBRARIES}
${PDAL_REEXPORT}
${PDAL_ARBITER_LIB_NAME}
${PDAL_H3_LIB_NAME}
${JSON_SCHEMA_LIB_NAME}
${PDAL_KAZHDAN_LIB_NAME}
${PDAL_LEPCC_LIB_NAME}
${PDAL_LAZPERF_LIB_NAME}
${UTFCPP_LIB_NAME}
${BACKTRACE_LIBRARIES}
"$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:-lstdc++fs>"
PUBLIC
${WINSOCK_LIBRARY}
INTERFACE
${PDAL_LIBDIR}
${WINSOCK_LIBRARY}
)
#
# Allow downstream cmake projects to find PDAL header files without
# being explicit.
#
target_include_directories(${PDAL_LIB_NAME}
INTERFACE
$<INSTALL_INTERFACE:include>)
target_compile_definitions(${PDAL_LIB_NAME}
PRIVATE
H3_PREFIX=PDALH3)
if(WIN32)
target_compile_definitions(${PDAL_LIB_NAME}
PUBLIC
PDAL_DLL_EXPORT=1
)
endif(WIN32)
set_target_properties(${PDAL_LIB_NAME} PROPERTIES
VERSION ${PDAL_BUILD_VERSION}
SOVERSION ${PDAL_API_VERSION}
CLEAN_DIRECT_OUTPUT 1)
# shut off -Wpedantic selectively
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
set_source_files_properties(filters/PoissonFilter.cpp PROPERTIES COMPILE_FLAGS "-Wno-pedantic -Wno-array-parameter")
endif()
#
# Installation
#
#
# Only install compression headers if we're building with the particular
# compression type.
#
if (NOT PDAL_HAVE_ZSTD)
set(ZSTD_EXCLUDES PATTERN pdal/compression/Zstd* EXCLUDE)
endif()
if (NOT PDAL_HAVE_ZLIB)
set(ZLIB_EXCLUDES PATTERN pdal/compression/Deflate* EXCLUDE)
endif()
if (NOT PDAL_HAVE_LZMA)
set(LZMA_EXCLUDES PATTERN pdal/compression/Lzma* EXCLUDE)
endif()
install(DIRECTORY ${PDAL_INCLUDE_DIR}/pdal/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/pdal"
FILES_MATCHING PATTERN "*.hpp"
PERMISSIONS
GROUP_EXECUTE WORLD_EXECUTE OWNER_EXECUTE
GROUP_READ WORLD_READ OWNER_READ
OWNER_WRITE
# PATTERN "pdal/private" EXCLUDE
# PATTERN "pdal/io/private" EXCLUDE
# PATTERN "pdal/pdal/private" EXCLUDE
# PATTERN "pdal/util/private" EXCLUDE
# PATTERN "pdal/filters/private" EXCLUDE
# ${ZSTD_EXCLUDES}
# ${ZLIB_EXCLUDES}
# ${LZMA_EXCLUDES}
)
install(DIRECTORY ${PDAL_KERNELS_DIR}/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/pdal/kernels"
FILES_MATCHING PATTERN "*.hpp"
PERMISSIONS
GROUP_EXECUTE WORLD_EXECUTE OWNER_EXECUTE
GROUP_READ WORLD_READ OWNER_READ
OWNER_WRITE
# PATTERN "private" EXCLUDE
)
install(DIRECTORY ${PDAL_IO_DIR}/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/pdal/io"
FILES_MATCHING PATTERN "*.hpp"
PERMISSIONS
GROUP_EXECUTE WORLD_EXECUTE OWNER_EXECUTE
GROUP_READ WORLD_READ OWNER_READ
OWNER_WRITE
# PATTERN "private" EXCLUDE
)
install(DIRECTORY ${PDAL_FILTERS_DIR}/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/pdal/filters"
FILES_MATCHING PATTERN "*.hpp"
PERMISSIONS
GROUP_EXECUTE WORLD_EXECUTE OWNER_EXECUTE
GROUP_READ WORLD_READ OWNER_READ
OWNER_WRITE
# PATTERN "private" EXCLUDE
)
install(FILES ${DIMENSION_OUTFILE} ${pdal_features_hpp}/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/pdal"
PERMISSIONS
GROUP_EXECUTE WORLD_EXECUTE OWNER_EXECUTE
GROUP_READ WORLD_READ OWNER_READ
OWNER_WRITE
)
install(FILES ${PDAL_CMAKE_DIR}/pluginmacros.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PDAL
PERMISSIONS
GROUP_EXECUTE WORLD_EXECUTE OWNER_EXECUTE
GROUP_READ WORLD_READ OWNER_READ
OWNER_WRITE
)
#
# CPACK
#
include (${PDAL_CMAKE_DIR}/cpack.cmake)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
export(
TARGETS
${PDAL_LIB_NAME}
FILE
"${PDAL_BINARY_DIR}/PDALTargets.cmake")
install(
EXPORT
PDALTargets
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/PDAL")
include(${PDAL_CMAKE_DIR}/config.cmake)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES)
# TODO: move under scripts/bash-completion ?
if (WITH_COMPLETION)
if (IS_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions)
install(
FILES
"${PROJECT_SOURCE_DIR}/scripts/bash-completion/pdal"
DESTINATION
"${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions")
elseif (IS_DIRECTORY /etc/bash_completion.d)
install(
FILES
"${PROJECT_SOURCE_DIR}/scripts/bash-completion/pdal"
DESTINATION
"${CMAKE_INSTALL_SYSCONFDIR}/bash_completion.d")
endif()
endif()