-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
92 lines (78 loc) · 2.51 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
cmake_minimum_required(VERSION 3.9)
# Set a name and a version number for your project:
project(
py4dgeo
VERSION 0.0.1
LANGUAGES CXX)
# Take into account <Package>_ROOT environment variable (used in packaging
# process)
cmake_policy(SET CMP0074 NEW)
# Initialize some default paths
include(GNUInstallDirs)
# Define the minimum C++ standard that is required
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 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")
# Check that the repository was clone recursively
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/ext/Catch2/CMakeLists.txt)
message(
FATAL_ERROR
"Submodules not found. py4dgeo needs to be either cloned with the"
"'--recursive' flag or 'git submodule update --init' needs to be called")
endif()
# Compile the library
add_library(py4dgeo lib/directions.cpp lib/distances.cpp lib/epoch.cpp
lib/kdtree.cpp lib/registration.cpp lib/segmentation.cpp)
target_include_directories(
py4dgeo PUBLIC ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/ext/eigen
${CMAKE_SOURCE_DIR}/ext/nanoflann/include)
if(PY4DGEO_WITH_OPENMP)
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()
# Compile the tests and benchmarks
include(CTest)
if(BUILD_TESTING)
add_subdirectory(ext/Catch2)
include(./ext/Catch2/contrib/Catch.cmake)
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()
# Add the documentation
if(BUILD_DOCS)
add_subdirectory(doc)
endif()
if(BUILD_PYTHON)
# Add Python bindings
add_subdirectory(ext/pybind11)
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()
# This prints a summary of found dependencies
include(FeatureSummary)
feature_summary(WHAT ALL)