forked from 3dgeo-heidelberg/py4dgeo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
163 lines (140 loc) · 3.65 KB
/
Copy pathCMakeLists.txt
File metadata and controls
163 lines (140 loc) · 3.65 KB
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
cmake_minimum_required(VERSION 3.30)
# ------------------------------------------------
# Set a name and a version number for the project:
# ------------------------------------------------
project(
py4dgeo
VERSION 1.0.0
LANGUAGES CXX)
# Take into account <Package>_ROOT environment variable (used in packaging
# process)
cmake_policy(SET CMP0074 NEW)
# Initialize some default paths
include(GNUInstallDirs)
# Enable PIC for Python bindings
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# -------------------
# Compilation options
# -------------------
set(BUILD_PYTHON
ON
CACHE BOOL "Enable building of Python bindings")
set(BUILD_DOCS
ON
CACHE BOOL "Enable building of documentation")
set(BUILD_BENCHMARKS
OFF
CACHE BOOL "Enable building of benchmark applications")
set(PY4DGEO_WITH_OPENMP
ON
CACHE BOOL "Enable OpenMP parallelization")
# ---------------------------
# Add the main library target
# ---------------------------
add_library(py4dgeo)
target_sources(py4dgeo
PRIVATE
lib/directions.cpp
lib/distances.cpp
lib/epoch.cpp
lib/kdtree.cpp
lib/octree.cpp
lib/registration.cpp
lib/segmentation.cpp
lib/searchtree.cpp
PUBLIC
FILE_SET HEADERS
BASE_DIRS
include
)
target_compile_features(py4dgeo
PUBLIC
cxx_std_17
)
# --------------------------------------
# Add nanoflann interface library target
# --------------------------------------
add_library(nanoflann INTERFACE)
target_sources(nanoflann
INTERFACE
FILE_SET nanoflann_headers
TYPE HEADERS
BASE_DIRS
ext/nanoflann/include
FILES
ext/nanoflann/include/nanoflann.hpp
)
target_compile_features(nanoflann
INTERFACE
cxx_std_11
)
# -----------------
# Eigen3 dependency
# -----------------
set(EIGEN_BUILD_TESTING OFF CACHE BOOL "Disable Eigen tests" FORCE)
add_subdirectory(ext/eigen EXCLUDE_FROM_ALL)
# -----------------------------------
# Link nanoflann and eigen to py4dgeo
# -----------------------------------
target_link_libraries(py4dgeo
PUBLIC
nanoflann
Eigen3::Eigen
)
# ------------------------------------------
# Enable OpenMP (if supported and requested)
# ------------------------------------------
if(PY4DGEO_WITH_OPENMP)
if(MSVC)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("/openmp:llvm" MSVC_SUPPORTS_OPENMP_LLVM)
if(MSVC_SUPPORTS_OPENMP_LLVM)
set(OpenMP_RUNTIME_MSVC "llvm")
endif()
endif()
find_package(OpenMP)
if(OpenMP_FOUND)
target_link_libraries(py4dgeo PUBLIC OpenMP::OpenMP_CXX)
target_compile_definitions(py4dgeo
PUBLIC
PY4DGEO_WITH_OPENMP
EIGEN_DONT_PARALLELIZE
)
endif()
endif()
# -------------------------------------
# Optionally build tests and benchmarks
# -------------------------------------
include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
if(BUILD_BENCHMARKS)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_ENABLE_TESTING OFF)
add_subdirectory(./ext/benchmark)
add_subdirectory(benchmarks)
endif()
# ---------------------
# Optionally build docs
# ---------------------
if(BUILD_DOCS)
add_subdirectory(doc)
endif()
# ------------------------------
# Optionally build Python module
# ------------------------------
if(BUILD_PYTHON)
# Add Python bindings
find_package(pybind11 CONFIG REQUIRED)
# Define Python extension module
pybind11_add_module(_py4dgeo MODULE src/py4dgeo/py4dgeo_python.cpp)
target_link_libraries(_py4dgeo PUBLIC py4dgeo)
# Install th Python module library target
install(TARGETS _py4dgeo DESTINATION .)
endif()
# -----------------------
# Show dependency summary
# -----------------------
include(FeatureSummary)
feature_summary(WHAT ALL)