-
Notifications
You must be signed in to change notification settings - Fork 131
/
CMakeLists.txt
112 lines (89 loc) · 3.97 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
cmake_minimum_required(VERSION 3.14)
project(CT_ICP)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
option(WITH_GTSAM "Search GTSAM dependency (disabled by default)" OFF)
option(WITH_VIZ3D "Search and install viz3d (disabled by default)" OFF)
option(WITH_PYTHON_BINDING "Install Python bindings" OFF)
set(LOG_PREFIX " [CT_ICP] -- ")
# --- Defining Install Location
if (NOT SUPERBUILD_INSTALL_DIR)
set(SUPERBUILD_INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/install)
get_filename_component(SUPERBUILD_INSTALL_DIR ${SUPERBUILD_INSTALL_DIR} ABSOLUTE)
message(INFO "${LOG_PREFIX}Variable \"SUPERBUILD_INSTALL_DIR\" not specified. Trying to set it to ${SUPERBUILD_INSTALL_DIR}")
endif ()
if (NOT SLAMCORE_INSTALL_DIR)
set(SLAMCORE_INSTALL_DIR ${SUPERBUILD_INSTALL_DIR}/SlamCore)
get_filename_component(SLAMCORE_INSTALL_DIR ${SLAMCORE_INSTALL_DIR} ABSOLUTE)
message(INFO "${LOG_PREFIX}Variable \"SLAMCORE_INSTALL_DIR\" not specified. Trying to set it to ${SLAMCORE_INSTALL_DIR}")
endif ()
if (NOT CT_ICP_INSTALL_DIR)
set(CT_ICP_INSTALL_DIR ${SUPERBUILD_INSTALL_DIR}/CT_ICP)
get_filename_component(CT_ICP_INSTALL_DIR ${CT_ICP_INSTALL_DIR} ABSOLUTE)
message(INFO "${LOG_PREFIX}Variable \"CT_ICP_INSTALL_DIR\" not specified. Trying to set it to ${CT_ICP_INSTALL_DIR}")
endif ()
# --- Include CMAKE scripts
include(cmake/includes.cmake)
include(cmake/viz3d_utils.cmake)
# ----------------------------------------------------------------------------------------------------------------------
# Define Default variables
SLAM_COMPILER_FLAGS()
if (UNIX)
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.1)
message(INFO "${LOG_PREFIX}GCC version detected is ${CMAKE_CXX_COMPILER_VERSION}. Adding the filesystem library with 'stdc++fs' flag.")
link_libraries(stdc++fs)
endif ()
endif ()
SLAM_DEFAULT_VARIABLES()
SLAM_INCLUDE_SUPERBUILD()
include(cmake/external.cmake)
SLAM_INSTALL_DEFAULT_VARIABLES(TARGET CT_ICP PREFIX CT_ICP)
set(CMAKE_INSTALL_PREFIX ${CT_ICP_INSTALL_DIR})
# ----------------------------------------------------------------------------------------------------------------------
# Check targets
find_package(OpenMP)
if (NOT TARGET OpenMP::OpenMP_CXX)
message(INFO "[CT_ICP] Could not find OpenMP")
endif ()
# -- Manually append to the RPATH for CT_ICP shared library the rpath to SlamCore
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${EXTERNAL_DEPENDENCIES_INSTALL_RPATH}:${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_subdirectory(src)
target_compile_definitions(CT_ICP PUBLIC CT_ICP_CPP_STANDARD=${CMAKE_CXX_STANDARD})
if (WITH_GTSAM)
find_package(GTSAM REQUIRED)
message(INFO ${LOG_PREFIX}"WITH_GTSAM=ON and target GTSAM found")
else ()
message(INFO ${LOG_PREFIX}"WITH_GTSAM=OFF gtsam dependent targets will not be built")
endif ()
# ---------------------
# Install Target
SLAM_INSTALL_TARGET(
TARGET SlamCore
CONFIG_TEMPLATE cmake/project_config.cmake.in
INSTALL_DIR ${CT_ICP_INSTALL_DIR}
INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
if (WITH_VIZ3D)
SLAM_INSTALL_TARGET(
TARGET SlamCore-viz3d
CONFIG_TEMPLATE cmake/project_config.cmake.in
INSTALL_DIR ${CT_ICP_INSTALL_DIR}
INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
endif ()
SLAM_INSTALL_TARGET(
TARGET CT_ICP
CONFIG_TEMPLATE cmake/project_config.cmake.in
INSTALL_DIR ${CT_ICP_INSTALL_DIR}
INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
if (WITH_VIZ3D)
SLAM_INSTALL_TARGET(
TARGET CT_ICP-viz3d
CONFIG_TEMPLATE cmake/project_config.cmake.in
INSTALL_DIR ${CT_ICP_INSTALL_DIR}
INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
endif ()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake DESTINATION ${CT_ICP_INSTALL_DIR}/lib/cmake)
add_subdirectory(test)
add_subdirectory(command)