forked from BehaviorTree/BehaviorTree.CPP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
224 lines (173 loc) · 6.4 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
cmake_minimum_required(VERSION 3.16.3) # version on Ubuntu Focal
project(behaviortree_cpp VERSION 4.2.0 LANGUAGES C CXX)
set(CMAKE_CONFIG_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CONFIG_PATH}")
set(BTCPP_LIBRARY ${PROJECT_NAME})
#---- Enable C++17 ----
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE "Release" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN)
else()
add_definitions(-Wpedantic)
endif()
#set(CMAKE_POSITION_INDEPENDENT_CODE ON)
#---- project configuration ----
option(BTCPP_SHARED_LIBS "Build shared libraries" ON)
option(BTCPP_BUILD_TOOLS "Build commandline tools" ON)
option(BTCPP_EXAMPLES "Build tutorials and examples" ON)
option(BTCPP_UNIT_TESTS "Build the unit tests" ON)
option(BTCPP_GROOT_INTERFACE "Add Groot2 connection. Requires ZeroMQ" ON)
option(BTCPP_SQLITE_LOGGING "Add SQLite logging." ON)
option(USE_V3_COMPATIBLE_NAMES "Use some alias to compile more easily old 3.x code" OFF)
if(USE_V3_COMPATIBLE_NAMES)
add_definitions(-DUSE_BTCPP3_OLD_NAMES)
endif()
#---- Find other packages ----
find_package(Threads REQUIRED)
set(BEHAVIOR_TREE_LIBRARY ${PROJECT_NAME})
# Update the policy setting to avoid an error when loading the ament_cmake package
# at the current cmake version level
if(POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
endif()
find_package(ament_cmake QUIET)
if ( ament_cmake_FOUND )
add_definitions( -DUSING_ROS2 )
message(STATUS "------------------------------------------")
message(STATUS "BehaviourTree is being built using AMENT.")
message(STATUS "------------------------------------------")
include(cmake/ament_build.cmake)
elseif( CATKIN_DEVEL_PREFIX OR CATKIN_BUILD_BINARY_PACKAGE)
add_definitions( -DUSING_ROS )
message(STATUS "------------------------------------------")
message(STATUS "BehaviourTree is being built using CATKIN.")
message(STATUS "------------------------------------------")
include(cmake/catkin_build.cmake)
set(catkin_FOUND TRUE)
else()
message(STATUS "------------------------------------------")
message(STATUS "BehaviourTree is being built with conan.")
message(STATUS "------------------------------------------")
include(cmake/conan_build.cmake)
endif()
#############################################################
# LIBRARY
add_subdirectory(3rdparty/lexy)
list(APPEND BT_SOURCE
src/action_node.cpp
src/basic_types.cpp
src/behavior_tree.cpp
src/blackboard.cpp
src/bt_factory.cpp
src/decorator_node.cpp
src/condition_node.cpp
src/control_node.cpp
src/shared_library.cpp
src/tree_node.cpp
src/script_parser.cpp
src/json_export.cpp
src/xml_parsing.cpp
src/actions/test_node.cpp
src/actions/sleep_node.cpp
src/decorators/inverter_node.cpp
src/decorators/repeat_node.cpp
src/decorators/retry_node.cpp
src/decorators/subtree_node.cpp
src/decorators/delay_node.cpp
src/controls/if_then_else_node.cpp
src/controls/fallback_node.cpp
src/controls/parallel_node.cpp
src/controls/reactive_sequence.cpp
src/controls/reactive_fallback.cpp
src/controls/sequence_node.cpp
src/controls/sequence_star_node.cpp
src/controls/switch_node.cpp
src/controls/while_do_else_node.cpp
src/loggers/bt_cout_logger.cpp
src/loggers/bt_file_logger_v2.cpp
src/loggers/bt_minitrace_logger.cpp
src/loggers/bt_observer.cpp
3rdparty/tinyxml2/tinyxml2.cpp
3rdparty/minitrace/minitrace.cpp
)
if(BTCPP_GROOT_INTERFACE)
# should be found already, at this stage
list(APPEND BT_SOURCE src/loggers/groot2_publisher.cpp )
endif()
if(BTCPP_SQLITE_LOGGING)
list(APPEND BT_SOURCE src/loggers/bt_sqlite_logger.cpp )
endif()
######################################################
if (UNIX)
list(APPEND BT_SOURCE src/shared_library_UNIX.cpp )
endif()
if (WIN32)
set(CMAKE_DEBUG_POSTFIX "d")
list(APPEND BT_SOURCE src/shared_library_WIN.cpp )
endif()
if (BTCPP_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_library(${BTCPP_LIBRARY} SHARED ${BT_SOURCE})
else()
add_library(${BTCPP_LIBRARY} STATIC ${BT_SOURCE})
endif()
message(STATUS "BTCPP_EXTRA_LIBRARIES: ${BTCPP_EXTRA_LIBRARIES}")
target_link_libraries(${BTCPP_LIBRARY}
PRIVATE
Threads::Threads
${CMAKE_DL_LIBS}
$<BUILD_INTERFACE:foonathan::lexy>
${BTCPP_EXTRA_LIBRARIES}
)
target_include_directories(${BTCPP_LIBRARY}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/3rdparty>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/lexy/include>
${BTCPP_EXTRA_INCLUDE_DIRS}
)
target_compile_definitions(${BTCPP_LIBRARY} PRIVATE $<$<CONFIG:Debug>:TINYXML2_DEBUG>)
target_compile_definitions(${BTCPP_LIBRARY} PUBLIC BTCPP_LIBRARY_VERSION="${CMAKE_PROJECT_VERSION}")
if(MSVC)
else()
target_compile_options(${BTCPP_LIBRARY} PRIVATE -Wall -Wextra)
endif()
#############################################################
message( STATUS "BTCPP_LIB_DESTINATION: ${BTCPP_LIB_DESTINATION} " )
message( STATUS "BTCPP_INCLUDE_DESTINATION: ${BTCPP_INCLUDE_DESTINATION} " )
message( STATUS "BTCPP_UNIT_TESTS: ${BTCPP_UNIT_TESTS} " )
add_subdirectory(sample_nodes)
######################################################
if (BTCPP_UNIT_TESTS)
add_subdirectory(tests)
endif()
if(BTCPP_BUILD_TOOLS)
add_subdirectory(tools)
endif()
if(BTCPP_EXAMPLES)
add_subdirectory(examples)
endif()
######################################################
# INSTALL
INSTALL(TARGETS ${BTCPP_LIBRARY}
EXPORT ${PROJECT_NAME}Targets
ARCHIVE DESTINATION ${BTCPP_LIB_DESTINATION}
LIBRARY DESTINATION ${BTCPP_LIB_DESTINATION}
RUNTIME DESTINATION ${BTCPP_BIN_DESTINATION}
INCLUDES DESTINATION ${BTCPP_INCLUDE_DESTINATION}
)
INSTALL( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${BTCPP_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h*")
export_btcpp_package()