Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ac383f4

Browse files
committed
fixed compilation on ROS2 and ubuntu 18.94
1 parent 5e8e2da commit ac383f4

File tree

2 files changed

+36
-28
lines changed

2 files changed

+36
-28
lines changed

CMakeLists.txt

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
cmake_minimum_required(VERSION 2.8.12) # version on Ubuntu Trusty
22
project(behaviortree_cpp_v3)
33

4+
#---- Add the subdirectory cmake ----
5+
set(CMAKE_CONFIG_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake")
6+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CONFIG_PATH}")
7+
8+
#---- Enable C++11 ----
49
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
510
set(CMAKE_CXX_STANDARD 11)
611
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -12,37 +17,36 @@ if(MSVC)
1217
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
1318
endif()
1419

15-
find_package(Boost COMPONENTS coroutine2 QUIET)
16-
20+
#---- Include boost to add coroutines ----
21+
find_package(Boost COMPONENTS coroutine QUIET)
1722
if(Boost_FOUND)
1823
include_directories(${Boost_INCLUDE_DIRS})
19-
message(STATUS "Found boost::coroutine2.")
20-
add_definitions(-DBT_BOOST_COROUTINE2)
21-
set(BT_COROUTINES true)
22-
else()
23-
find_package(Boost COMPONENTS coroutine QUIET)
24-
if(Boost_FOUND)
25-
message(STATUS "Found boost::coroutine.")
26-
include_directories(${Boost_INCLUDE_DIRS})
27-
add_definitions(-DBT_BOOST_COROUTINE)
28-
set(BT_COROUTINES true)
29-
else()
30-
add_definitions(-DBT_NO_COROUTINES)
31-
endif()
24+
if(Boost_VERSION VERSION_GREATER_EQUAL 105900)
25+
message(STATUS "Found boost::coroutine2.")
26+
add_definitions(-DBT_BOOST_COROUTINE2)
27+
set(BT_COROUTINES true)
28+
elseif(Boost_VERSION_STRING VERSION_GREATER_EQUAL 105300)
29+
message(STATUS "Found boost::coroutine.")
30+
include_directories(${Boost_INCLUDE_DIRS})
31+
add_definitions(-DBT_BOOST_COROUTINE)
32+
set(BT_COROUTINES true)
33+
endif()
3234
endif()
3335

34-
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
36+
if(NOT DEFINED BT_COROUTINES)
37+
message(STATUS "Coroutines disabled. Install Boost to enable them (version 1.59+ recommended).")
38+
add_definitions(-DBT_NO_COROUTINES)
39+
endif()
3540

36-
set(CMAKE_CONFIG_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake")
37-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CONFIG_PATH}")
41+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
3842

43+
#---- project configuration ----
3944
option(BUILD_EXAMPLES "Build tutorials and examples" ON)
4045
option(BUILD_UNIT_TESTS "Build the unit tests" ON)
4146
option(BUILD_TOOLS "Build commandline tools" ON)
4247
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
4348

44-
#############################################################
45-
# Find packages
49+
#---- Find other packages ----
4650
find_package(Threads)
4751
find_package(ZMQ)
4852

@@ -62,7 +66,6 @@ endif()
6266

6367
set(BEHAVIOR_TREE_LIBRARY ${PROJECT_NAME})
6468

65-
6669
# Update the policy setting to avoid an error when loading the ament_cmake package
6770
# at the current cmake version level
6871
if(POLICY CMP0057)
@@ -230,7 +233,7 @@ endif()
230233

231234
######################################################
232235
# INSTALL
233-
set(PROJECT_NAMESPACE BehaviorTree)
236+
set(PROJECT_NAMESPACE BehaviorTreeV3)
234237
set(PROJECT_CONFIG ${PROJECT_NAMESPACE}Config)
235238

236239
INSTALL(TARGETS ${BEHAVIOR_TREE_LIBRARY}

package.xml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<package>
1+
<?xml version="1.0"?>
2+
<package format="3">
23
<name>behaviortree_cpp_v3</name>
34
<version>3.1.1</version>
45
<description>
@@ -12,12 +13,16 @@
1213
<author>Michele Colledanchise</author>
1314
<author>Davide Faconti</author>
1415

15-
<build_depend>roslib</build_depend>
16-
<run_depend>roslib</run_depend>
16+
<buildtool_depend condition="$ROS_VERSION == 1">catkin</buildtool_depend>
17+
<depend condition="$ROS_VERSION == 1">roslib</depend>
1718

18-
<build_depend>libzmq3-dev</build_depend>
19-
<run_depend>libzmq3-dev</run_depend>
19+
<buildtool_depend condition="$ROS_VERSION == 2">ament_cmake</buildtool_depend>
20+
<depend condition="$ROS_VERSION == 2">rclcpp</depend>
2021

21-
<buildtool_depend>catkin</buildtool_depend>
22+
<depend>libzmq3-dev</depend>
23+
24+
<export>
25+
<build_type condition="$ROS_VERSION == 2">ament_cmake</build_type>
26+
</export>
2227

2328
</package>

0 commit comments

Comments
 (0)