-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathCMakeLists.txt
128 lines (109 loc) · 3.92 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
# ------------------------------------------------------------------------------
# Multi primitive-to-primitive (MP2P) ICP C++ library
#
# Copyright (C) 2018-2020, Jose Luis Blanco-Claraco, contributors (AUTHORS.md)
# All rights reserved.
# Released under BSD 3-Clause License. See COPYING.
# ------------------------------------------------------------------------------
# Minimum CMake version: deprecated if <3.5 (as of Apr 2024)
cmake_minimum_required(VERSION 3.5)
if("$ENV{ROS_VERSION}" STREQUAL "2")
set(DETECTED_ROS2 TRUE)
elseif("$ENV{ROS_VERSION}" STREQUAL "1")
set(DETECTED_ROS1 TRUE)
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(default_build_type "Release")
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
endif()
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "SanitizeAddress" "SanitizeThread")
# Tell CMake we'll use C++ for use in its tests/flags
project(mp2p_icp LANGUAGES CXX)
# MOLA CMake scripts: "mola_xxx()"
# to allow stand-along builds outside of MOLA, use local copy instead:
find_package(mola_common QUIET)
if(NOT mola_common_FOUND)
message(STATUS "Standalone ${PROJECT_NAME} build: using mola_common from submodule.")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mola_common-build")
execute_process(COMMAND
${CMAKE_COMMAND} ${PROJECT_SOURCE_DIR}/3rdparty/mola_common -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/mola_common-install
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mola_common-build
)
execute_process(COMMAND
${CMAKE_COMMAND} --build . --target install
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mola_common-build
)
# 2nd attempt:
set(mola_common_DIR ${CMAKE_CURRENT_BINARY_DIR}/mola_common-install/share/mola_common/cmake/)
find_package(mola_common REQUIRED)
endif()
# 3rd party:
add_subdirectory(3rdparty)
# find dependencies:
find_package(MRPT 2.11.5 REQUIRED COMPONENTS
containers
tfest
maps
gui
topography
)
find_package(Threads REQUIRED)
find_package(TBB) # optional
if(TBB_FOUND)
option(MP2PICP_USE_TBB "If found TBB, this option controls whether to use it or not" ON)
endif()
#----
# Extract version from package.xml
# Example line:" <version>0.3.2</version>"
file(READ package.xml contentPackageXML)
string(REGEX MATCH "<version>([0-9\.]*)</version>" _ ${contentPackageXML})
set(MP2P_ICP_VERSION ${CMAKE_MATCH_1})
message(STATUS "MP2P_ICP version: ${MP2P_ICP_VERSION} (detected in package.xml)")
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" _ ${MP2P_ICP_VERSION})
set(MP2P_ICP_MAJOR_VERSION ${CMAKE_MATCH_1})
set(MP2P_ICP_MINOR_VERSION ${CMAKE_MATCH_2})
set(MP2P_ICP_PATCH_VERSION ${CMAKE_MATCH_3})
#----
# -----------------------
# define library targets:
# -----------------------
# Metric map container library:
add_subdirectory(mp2p_icp_map)
# Main mp2p_icp library:
add_subdirectory(mp2p_icp)
# Basic filters library:
add_subdirectory(mp2p_icp_filters)
# -----------------------
# define tests:
# -----------------------
option(MP2PICP_BUILD_TESTING "Build unit tests" ON)
if(MP2PICP_BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
# -----------------------
# define apps:
# -----------------------
option(MP2PICP_BUILD_APPLICATIONS "Build mp2p_icp applications" ON)
if(MP2PICP_BUILD_APPLICATIONS)
add_subdirectory(apps)
endif()
if(DETECTED_ROS1)
# Find catkin macros and libraries
# if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
# is used, also find other catkin packages
find_package(catkin
REQUIRED
#COMPONENTS
#roscpp tf2 dynamic_reconfigure std_msgs nav_msgs sensor_msgs visualization_msgs
#tf2_geometry_msgs
)
catkin_package(
#CATKIN_DEPENDS tf2 tf2_geometry_msgs
# INCLUDE_DIRS include
# LIBRARIES mrpt_localization
# DEPENDS mrpt
)
endif()