@@ -18,41 +18,48 @@ endif()
18
18
set (CMAKE_POSITION_INDEPENDENT_CODE ON )
19
19
20
20
#---- project configuration ----
21
- option (BUILD_EXAMPLES "Build tutorials and examples" ON )
22
- option (BUILD_SAMPLES "Build sample nodes" ON )
23
- option (BUILD_UNIT_TESTS "Build the unit tests" ON )
24
- option (BUILD_TOOLS "Build commandline tools" ON )
25
- option (BUILD_SHARED_LIBS "Build shared libraries" ON )
26
- option (BUILD_MANUAL_SELECTOR "Build manual selector node" ON )
27
- option (ENABLE_COROUTINES "Enable boost coroutines" ON )
21
+ option (BTCPP_SHARED_LIBS "Build shared libraries" ON )
22
+ option (BTCPP_ENABLE_COROUTINES "Enable boost coroutines" ON )
23
+ option (BTCPP_MANUAL_SELECTOR "Build manual selector node" ON )
24
+
25
+ if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} )
26
+ option (BTCPP_EXAMPLES "Build tutorials and examples" ON )
27
+ option (BTCPP_UNIT_TESTS "Build the unit tests" ON )
28
+ option (BTCPP_BUILD_TOOLS "Build commandline tools" ON )
29
+ else ()
30
+ option (BTCPP_EXAMPLES "Build tutorials and examples" OFF )
31
+ option (BTCPP_UNIT_TESTS "Build the unit tests" OFF )
32
+ option (BTCPP_BUILD_TOOLS "Build commandline tools" OFF )
33
+ endif ()
34
+
28
35
option (USE_V3_COMPATIBLE_NAMES "Use some alias to compile more easily old 3.x code" OFF )
29
36
30
37
#---- Include boost to add coroutines ----
31
- if (ENABLE_COROUTINES )
38
+ if (BTCPP_ENABLE_COROUTINES )
32
39
find_package (Boost COMPONENTS coroutine QUIET )
33
40
34
41
if (Boost_FOUND )
35
42
string (REPLACE "." "0" Boost_VERSION_NODOT ${Boost_VERSION} )
36
43
if (NOT Boost_VERSION_NODOT VERSION_LESS 105900 )
37
44
message (STATUS "Found boost::coroutine2." )
38
45
add_definitions (-DBT_BOOST_COROUTINE2 )
39
- set (BT_COROUTINES true )
46
+ set (BT_COROUTINES_FOUND true )
40
47
elseif (NOT Boost_VERSION_NODOT VERSION_LESS 105300 )
41
48
message (STATUS "Found boost::coroutine." )
42
49
add_definitions (-DBT_BOOST_COROUTINE )
43
- set (BT_COROUTINES true )
50
+ set (BT_COROUTINES_FOUND true )
44
51
endif ()
45
52
include_directories (${Boost_INCLUDE_DIRS} )
46
53
endif ()
47
54
48
- if (NOT DEFINED BT_COROUTINES )
55
+ if (NOT DEFINED BT_COROUTINES_FOUND )
49
56
message (STATUS "Boost coroutines disabled. Install Boost (version 1.59+ recommended)." )
50
57
endif ()
51
58
else ()
52
59
message (STATUS "Boost coroutines disabled by CMake option." )
53
60
endif ()
54
61
55
- if (NOT DEFINED BT_COROUTINES )
62
+ if (NOT DEFINED BT_COROUTINES_FOUND )
56
63
add_definitions (-DBT_NO_COROUTINES )
57
64
endif ()
58
65
@@ -116,7 +123,7 @@ elseif( CATKIN_DEVEL_PREFIX OR CATKIN_BUILD_BINARY_PACKAGE)
116
123
list (APPEND BEHAVIOR_TREE_PUBLIC_LIBRARIES ${catkin_LIBRARIES} )
117
124
set (BUILD_TOOL_INCLUDE_DIRS ${catkin_INCLUDE_DIRS} )
118
125
119
- elseif (BUILD_UNIT_TESTS )
126
+ elseif (BTCPP_UNIT_TESTS )
120
127
if (${CMAKE_VERSION} VERSION_LESS "3.11.0" )
121
128
find_package (GTest REQUIRED )
122
129
else ()
@@ -175,7 +182,7 @@ list(APPEND BT_SOURCE
175
182
3rdparty/minitrace/minitrace.cpp
176
183
)
177
184
178
- if (BUILD_MANUAL_SELECTOR )
185
+ if (BTCPP_MANUAL_SELECTOR )
179
186
find_package (Curses QUIET )
180
187
if (CURSES_FOUND )
181
188
list (APPEND BT_SOURCE
@@ -211,13 +218,13 @@ if( ZMQ_FOUND )
211
218
list (APPEND BUILD_TOOL_INCLUDE_DIRS ${ZMQ_INCLUDE_DIRS} )
212
219
endif ()
213
220
214
- target_link_libraries (${BEHAVIOR_TREE_LIBRARY} PUBLIC
215
- ${BEHAVIOR_TREE_PUBLIC_LIBRARIES} )
216
-
217
- target_link_libraries ( ${BEHAVIOR_TREE_LIBRARY} PRIVATE
218
- ${Boost_LIBRARIES}
219
- ${ZMQ_LIBRARIES}
220
- foonathan::lexy
221
+ target_link_libraries (${BEHAVIOR_TREE_LIBRARY}
222
+ PUBLIC
223
+ ${BEHAVIOR_TREE_PUBLIC_LIBRARIES}
224
+ PRIVATE
225
+ ${Boost_LIBRARIES}
226
+ ${ZMQ_LIBRARIES}
227
+ $< BUILD_INTERFACE: foonathan::lexy>
221
228
)
222
229
223
230
#get_target_property(my_libs ${BEHAVIOR_TREE_LIBRARY} INTERFACE_LINK_LIBRARIES)
@@ -229,12 +236,15 @@ target_link_libraries(${BEHAVIOR_TREE_LIBRARY} PRIVATE
229
236
target_compile_definitions (${BEHAVIOR_TREE_LIBRARY} PRIVATE $< $< CONFIG:Debug> :TINYXML2_DEBUG> )
230
237
231
238
target_include_directories (${BEHAVIOR_TREE_LIBRARY} PUBLIC
232
- $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /3rdparty>
233
- $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /3rdparty/lexy/include>
234
239
$< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include>
235
240
$< INSTALL_INTERFACE:include>
236
241
${BUILD_TOOL_INCLUDE_DIRS} )
237
242
243
+ target_include_directories (${BEHAVIOR_TREE_LIBRARY} PRIVATE
244
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /3rdparty>
245
+ $< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /3rdparty/lexy/include>
246
+ )
247
+
238
248
if ( ZMQ_FOUND )
239
249
target_compile_definitions (${BEHAVIOR_TREE_LIBRARY} PUBLIC ZMQ_FOUND )
240
250
endif ()
@@ -271,18 +281,13 @@ endif()
271
281
272
282
message ( STATUS "BEHAVIOR_TREE_LIB_DESTINATION: ${BEHAVIOR_TREE_LIB_DESTINATION} " )
273
283
message ( STATUS "BEHAVIOR_TREE_BIN_DESTINATION: ${BEHAVIOR_TREE_BIN_DESTINATION} " )
274
- message ( STATUS "BUILD_UNIT_TESTS : ${BUILD_UNIT_TESTS } " )
284
+ message ( STATUS "BTCPP_UNIT_TESTS : ${BTCPP_UNIT_TESTS } " )
275
285
276
-
277
- ######################################################
278
- # Samples
279
- if (BUILD_SAMPLES )
280
- add_subdirectory (sample_nodes )
281
- endif ()
286
+ add_subdirectory (sample_nodes )
282
287
283
288
######################################################
284
289
# Test
285
- if (BUILD_UNIT_TESTS AND BUILD_SAMPLES )
290
+ if (BTCPP_UNIT_TESTS )
286
291
add_subdirectory (tests )
287
292
endif ()
288
293
@@ -333,10 +338,10 @@ install(
333
338
334
339
######################################################
335
340
# EXAMPLES and TOOLS
336
- if (BUILD_TOOLS )
341
+ if (BTCPP_BUILD_TOOLS )
337
342
add_subdirectory (tools )
338
343
endif ()
339
344
340
- if (BUILD_EXAMPLES AND BUILD_SAMPLES )
345
+ if (BTCPP_EXAMPLES )
341
346
add_subdirectory (examples )
342
347
endif ()
0 commit comments