@@ -18,41 +18,48 @@ endif()
1818set (CMAKE_POSITION_INDEPENDENT_CODE ON )
1919
2020#---- 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+
2835option (USE_V3_COMPATIBLE_NAMES "Use some alias to compile more easily old 3.x code" OFF )
2936
3037#---- Include boost to add coroutines ----
31- if (ENABLE_COROUTINES )
38+ if (BTCPP_ENABLE_COROUTINES )
3239 find_package (Boost COMPONENTS coroutine QUIET )
3340
3441 if (Boost_FOUND)
3542 string (REPLACE "." "0" Boost_VERSION_NODOT ${Boost_VERSION} )
3643 if (NOT Boost_VERSION_NODOT VERSION_LESS 105900)
3744 message (STATUS "Found boost::coroutine2." )
3845 add_definitions (-DBT_BOOST_COROUTINE2)
39- set (BT_COROUTINES true )
46+ set (BT_COROUTINES_FOUND true )
4047 elseif (NOT Boost_VERSION_NODOT VERSION_LESS 105300)
4148 message (STATUS "Found boost::coroutine." )
4249 add_definitions (-DBT_BOOST_COROUTINE)
43- set (BT_COROUTINES true )
50+ set (BT_COROUTINES_FOUND true )
4451 endif ()
4552 include_directories (${Boost_INCLUDE_DIRS} )
4653 endif ()
4754
48- if (NOT DEFINED BT_COROUTINES )
55+ if (NOT DEFINED BT_COROUTINES_FOUND )
4956 message (STATUS "Boost coroutines disabled. Install Boost (version 1.59+ recommended)." )
5057 endif ()
5158else ()
5259 message (STATUS "Boost coroutines disabled by CMake option." )
5360endif ()
5461
55- if (NOT DEFINED BT_COROUTINES )
62+ if (NOT DEFINED BT_COROUTINES_FOUND )
5663 add_definitions (-DBT_NO_COROUTINES)
5764endif ()
5865
@@ -116,7 +123,7 @@ elseif( CATKIN_DEVEL_PREFIX OR CATKIN_BUILD_BINARY_PACKAGE)
116123 list (APPEND BEHAVIOR_TREE_PUBLIC_LIBRARIES ${catkin_LIBRARIES} )
117124 set (BUILD_TOOL_INCLUDE_DIRS ${catkin_INCLUDE_DIRS} )
118125
119- elseif (BUILD_UNIT_TESTS )
126+ elseif (BTCPP_UNIT_TESTS )
120127 if (${CMAKE_VERSION} VERSION_LESS "3.11.0" )
121128 find_package (GTest REQUIRED)
122129 else ()
@@ -175,7 +182,7 @@ list(APPEND BT_SOURCE
175182 3rdparty/minitrace/minitrace.cpp
176183 )
177184
178- if (BUILD_MANUAL_SELECTOR )
185+ if (BTCPP_MANUAL_SELECTOR )
179186 find_package (Curses QUIET )
180187 if (CURSES_FOUND)
181188 list (APPEND BT_SOURCE
@@ -211,13 +218,13 @@ if( ZMQ_FOUND )
211218 list (APPEND BUILD_TOOL_INCLUDE_DIRS ${ZMQ_INCLUDE_DIRS} )
212219endif ()
213220
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>
221228)
222229
223230#get_target_property(my_libs ${BEHAVIOR_TREE_LIBRARY} INTERFACE_LINK_LIBRARIES)
@@ -229,12 +236,15 @@ target_link_libraries(${BEHAVIOR_TREE_LIBRARY} PRIVATE
229236target_compile_definitions (${BEHAVIOR_TREE_LIBRARY} PRIVATE $<$<CONFIG:Debug>:TINYXML2_DEBUG>)
230237
231238target_include_directories (${BEHAVIOR_TREE_LIBRARY} PUBLIC
232- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /3rdparty>
233- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /3rdparty/lexy/include >
234239 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
235240 $<INSTALL_INTERFACE:include >
236241 ${BUILD_TOOL_INCLUDE_DIRS} )
237242
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+
238248if ( ZMQ_FOUND )
239249 target_compile_definitions (${BEHAVIOR_TREE_LIBRARY} PUBLIC ZMQ_FOUND)
240250endif ()
@@ -271,18 +281,13 @@ endif()
271281
272282message ( STATUS "BEHAVIOR_TREE_LIB_DESTINATION: ${BEHAVIOR_TREE_LIB_DESTINATION} " )
273283message ( 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 } " )
275285
276-
277- ######################################################
278- # Samples
279- if (BUILD_SAMPLES)
280- add_subdirectory (sample_nodes)
281- endif ()
286+ add_subdirectory (sample_nodes)
282287
283288######################################################
284289# Test
285- if (BUILD_UNIT_TESTS AND BUILD_SAMPLES )
290+ if (BTCPP_UNIT_TESTS )
286291 add_subdirectory (tests)
287292endif ()
288293
@@ -333,10 +338,10 @@ install(
333338
334339######################################################
335340# EXAMPLES and TOOLS
336- if (BUILD_TOOLS )
341+ if (BTCPP_BUILD_TOOLS )
337342 add_subdirectory (tools)
338343endif ()
339344
340- if (BUILD_EXAMPLES AND BUILD_SAMPLES )
345+ if (BTCPP_EXAMPLES )
341346 add_subdirectory (examples)
342347endif ()
0 commit comments