Skip to content

Commit faa684c

Browse files
committed
fix error #473 and change name of CMake options
1 parent 9c56fd9 commit faa684c

File tree

5 files changed

+92
-41
lines changed

5 files changed

+92
-41
lines changed

.github/workflows/cmake.yml renamed to .github/workflows/cmake_ubuntu.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: cmake
1+
name: cmake Ubuntu
22

33
on: [push, pull_request]
44

@@ -15,14 +15,13 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
18-
os: [ubuntu-latest, windows-latest]
18+
os: [ubuntu-20.04]
1919

2020
steps:
2121
- uses: actions/checkout@v2
2222

2323
- name: Install Dependencies (Linux)
2424
run: sudo apt-get install libboost-dev libzmq3-dev
25-
if: matrix.os == 'ubuntu-latest'
2625

2726
- name: Create Build Environment
2827
# Some projects don't allow in-source building, so create a separate build directory
@@ -34,8 +33,8 @@ jobs:
3433
# access regardless of the host operating system
3534
shell: bash
3635
working-directory: ${{github.workspace}}/build
37-
# Note the current convention is to use the -S and -B options here to specify source
38-
# and build directories, but this is only available with CMake 3.13 and higher.
36+
# Note the current convention is to use the -S and -B options here to specify source
37+
# and build directories, but this is only available with CMake 3.13 and higher.
3938
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
4039
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
4140

@@ -46,7 +45,6 @@ jobs:
4645
run: cmake --build . --config $BUILD_TYPE
4746

4847
- name: run test (Linux)
49-
if: matrix.os == 'ubuntu-latest'
5048
working-directory: ${{github.workspace}}/build
5149
run: ./tests/behaviortree_cpp_test
5250

.github/workflows/cmake_windows.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: cmake Windows
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
7+
BUILD_TYPE: Release
8+
9+
jobs:
10+
build:
11+
# The CMake configure and build commands are platform agnostic and should work equally
12+
# well on Windows or Mac. You can convert this to a matrix build if you need
13+
# cross-platform coverage.
14+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [windows-latest]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Create Build Environment
24+
# Some projects don't allow in-source building, so create a separate build directory
25+
# We'll use this as our working directory for all subsequent commands
26+
run: cmake -E make_directory ${{github.workspace}}/build
27+
28+
- name: Configure CMake
29+
# Use a bash shell so we can use the same syntax for environment variable
30+
# access regardless of the host operating system
31+
shell: bash
32+
working-directory: ${{github.workspace}}/build
33+
# Note the current convention is to use the -S and -B options here to specify source
34+
# and build directories, but this is only available with CMake 3.13 and higher.
35+
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
36+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
37+
38+
- name: Build
39+
working-directory: ${{github.workspace}}/build
40+
shell: bash
41+
# Execute the build. You can specify a specific target with "--target <NAME>"
42+
run: cmake --build . --config $BUILD_TYPE
43+
44+
- name: run test (Windows)
45+
working-directory: ${{github.workspace}}/build
46+
run: ./tests/Release/behaviortree_cpp_test
47+

CMakeLists.txt

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,48 @@ endif()
1818
set(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+
2835
option(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()
5158
else()
5259
message(STATUS "Boost coroutines disabled by CMake option.")
5360
endif()
5461

55-
if(NOT DEFINED BT_COROUTINES)
62+
if(NOT DEFINED BT_COROUTINES_FOUND)
5663
add_definitions(-DBT_NO_COROUTINES)
5764
endif()
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})
212219
endif()
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
229236
target_compile_definitions(${BEHAVIOR_TREE_LIBRARY} PRIVATE $<$<CONFIG:Debug>:TINYXML2_DEBUG>)
230237

231238
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>
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+
238248
if( ZMQ_FOUND )
239249
target_compile_definitions(${BEHAVIOR_TREE_LIBRARY} PUBLIC ZMQ_FOUND)
240250
endif()
@@ -271,18 +281,13 @@ endif()
271281

272282
message( STATUS "BEHAVIOR_TREE_LIB_DESTINATION: ${BEHAVIOR_TREE_LIB_DESTINATION} " )
273283
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} " )
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)
287292
endif()
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)
338343
endif()
339344

340-
if(BUILD_EXAMPLES AND BUILD_SAMPLES)
345+
if(BTCPP_EXAMPLES)
341346
add_subdirectory(examples)
342347
endif()

tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ set(BT_TESTS
2424
script_parser_test.cpp
2525
)
2626

27-
if( BT_COROUTINES )
27+
if( BTCPP_ENABLE_COROUTINES AND BT_COROUTINES_FOUND )
2828
LIST( APPEND BT_TESTS gtest_coroutines.cpp)
2929
endif()
3030

@@ -60,7 +60,7 @@ elseif(catkin_FOUND AND CATKIN_ENABLE_TESTING)
6060

6161
target_include_directories(${BEHAVIOR_TREE_LIBRARY}_test PRIVATE gtest/include)
6262

63-
elseif(BUILD_UNIT_TESTS)
63+
elseif(BTCPP_UNIT_TESTS)
6464

6565
enable_testing()
6666

tools/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cmake_minimum_required(VERSION 3.5)
22

3+
include_directories(${CMAKE_SOURCE_DIR}/3rdparty)
34

45
add_executable(bt3_log_cat bt_log_cat.cpp )
56
target_link_libraries(bt3_log_cat ${BEHAVIOR_TREE_LIBRARY} )

0 commit comments

Comments
 (0)