forked from vb44/SiMpLE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
169 lines (142 loc) · 5.74 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
# Minimum CMake vesion: limited by CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
cmake_minimum_required(VERSION 3.4)
if("$ENV{ROS_VERSION}" STREQUAL "2")
set(DETECTED_ROS2 TRUE)
endif()
# Tell CMake we'll use C++ for use in its tests/flags
project(mola_simple_wrapper LANGUAGES CXX)
# MOLA CMake scripts: "mola_xxx()"
find_package(mola_common REQUIRED)
# find dependencies:
find_package(mrpt-maps REQUIRED)
find_package(mrpt-tclap REQUIRED)
find_mola_package(mola_kernel)
# CLI apps
# ---------------------------------
find_package(mola_input_kitti_dataset) # optional
find_package(mola_input_kitti360_dataset) # optional
find_package(mola_input_rawlog) # optional
find_package(mola_input_mulran_dataset) # optional
find_package(mola_input_rosbag2) # optional
find_package(mola_input_paris_luco_dataset) # optional
# --------------------------
# Dependency: DLib
# --------------------------
set(EMBEDDED_dlib_SOURCE_DIR "${${PROJECT_NAME}_SOURCE_DIR}/3rdparty/dlib-19.24")
set(EMBEDDED_dlib_BUILD_DIR "${${PROJECT_NAME}_BINARY_DIR}/3rdparty/dlib/")
set(EMBEDDED_dlib_INSTALL_DIR "${${PROJECT_NAME}_BINARY_DIR}/3rdparty/dlib/install/")
set(EMBEDDED_dlib_DIR "${EMBEDDED_dlib_INSTALL_DIR}/lib/cmake/dlib/")
if (TRUE)
message(STATUS "--- Running CMake on external submodule 'dlib'...")
file(MAKE_DIRECTORY "${EMBEDDED_dlib_BUILD_DIR}")
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.15")
set(echo_flag COMMAND_ECHO STDOUT)
endif()
execute_process(COMMAND
${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" "${EMBEDDED_dlib_SOURCE_DIR}"
-DDLIB_NO_GUI_SUPPORT=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_INSTALL_PREFIX=${EMBEDDED_dlib_INSTALL_DIR}
RESULT_VARIABLE result
WORKING_DIRECTORY "${EMBEDDED_dlib_BUILD_DIR}"
${echo_flag}
)
if(result)
message(FATAL_ERROR "CMake step for dlib failed: ${result}")
endif()
execute_process(COMMAND
${CMAKE_COMMAND} --build ${EMBEDDED_dlib_BUILD_DIR} --parallel --target install
RESULT_VARIABLE result
${echo_flag}
)
if(result)
message(FATAL_ERROR "CMake make install step for dlib failed: ${result}")
endif()
message(STATUS "--- End running CMake")
# Search again:
set(dlib_DIR "${EMBEDDED_dlib_DIR}" CACHE PATH "Path to dlib CMake config file" FORCE)
mark_as_advanced(dlib_DIR)
find_package(dlib CONFIG REQUIRED)
# install the embedded copy too (we need dlib-config.cmake, etc.)
execute_process(COMMAND
${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" "${EMBEDDED_dlib_SOURCE_DIR}"
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
RESULT_VARIABLE result
WORKING_DIRECTORY "${EMBEDDED_dlib_BUILD_DIR}"
${echo_flag}
)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build \"${EMBEDDED_dlib_BUILD_DIR}\" --target install)")
endif()
if (NOT dlib_FOUND)
message(FATAL_ERROR "dlib not found, neither as system library nor git submodule. Check error messages above for possible reasons.")
endif()
# SiMpLE:
# ----------------------------
#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/upstream/src ${CMAKE_CURRENT_BINARY_DIR}/simple)
#target_link_libraries(mola-lidar-odometry-cli-simple kiss_icp::pipeline)
# Find the required packages.
find_package(nanoflann REQUIRED)
find_package(TBB REQUIRED)
# For some reason, we must use the direct include instead of find_package() for dlib or the target is not defined (JLBC) (!!??)
#find_package(dlib CONFIG REQUIRED)
include("${EMBEDDED_dlib_DIR}/dlib.cmake")
find_package(Threads REQUIRED)
find_package(yaml-cpp REQUIRED)
# Add an executable called simple.
# simple MOLA CLI interface:
mola_add_executable(
TARGET mola-lidar-odometry-cli-simple
SOURCES
apps/mola-lidar-odometry-cli-simple.cpp
${CMAKE_CURRENT_SOURCE_DIR}/upstream/src/ObjectiveFunction.cpp
${CMAKE_CURRENT_SOURCE_DIR}/upstream/src/ConfigParser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/upstream/src/Scan.cpp
${CMAKE_CURRENT_SOURCE_DIR}/upstream/src/Map.cpp
${CMAKE_CURRENT_SOURCE_DIR}/upstream/src/Register.cpp
${CMAKE_CURRENT_SOURCE_DIR}/upstream/src/utils.cpp
LINK_LIBRARIES
mrpt::maps
mrpt::tclap
mola::mola_kernel
nanoflann::nanoflann
dlib::dlib
TBB::tbb
${YAML_CPP_LIBRARIES}
)
target_include_directories(mola-lidar-odometry-cli-simple PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/upstream/src)
# MOLA dataset input modules:
if (mola_input_kitti_dataset_FOUND)
target_link_libraries(mola-lidar-odometry-cli-simple mola::mola_input_kitti_dataset)
target_compile_definitions(mola-lidar-odometry-cli-simple PRIVATE HAVE_MOLA_INPUT_KITTI)
endif()
if (mola_input_kitti360_dataset_FOUND)
target_link_libraries(mola-lidar-odometry-cli-simple mola::mola_input_kitti360_dataset)
target_compile_definitions(mola-lidar-odometry-cli-simple PRIVATE HAVE_MOLA_INPUT_KITTI360)
endif()
if (mola_input_mulran_dataset_FOUND)
target_link_libraries(mola-lidar-odometry-cli-simple mola::mola_input_mulran_dataset)
target_compile_definitions(mola-lidar-odometry-cli-simple PRIVATE HAVE_MOLA_INPUT_MULRAN)
endif()
if (mola_input_rawlog_FOUND)
target_link_libraries(mola-lidar-odometry-cli-simple mola::mola_input_rawlog)
target_compile_definitions(mola-lidar-odometry-cli-simple PRIVATE HAVE_MOLA_INPUT_RAWLOG)
endif()
if (mola_input_rosbag2_FOUND)
target_link_libraries(mola-lidar-odometry-cli-simple mola::mola_input_rosbag2)
target_compile_definitions(mola-lidar-odometry-cli-simple PRIVATE HAVE_MOLA_INPUT_ROSBAG2)
endif()
if (mola_input_paris_luco_dataset_FOUND)
target_link_libraries(mola-lidar-odometry-cli-simple mola::mola_input_paris_luco_dataset)
target_compile_definitions(mola-lidar-odometry-cli-simple PRIVATE HAVE_MOLA_INPUT_PARIS_LUCO)
endif()
# -----------------------------------------------------------------------------
# ROS2
# -----------------------------------------------------------------------------
if (DETECTED_ROS2)
# find dependencies
find_package(ament_cmake REQUIRED)
#ament_target_dependencies(MY_TARGET
# rclcpp...
#)
ament_package()
endif()