diff --git a/CMakeLists.txt b/CMakeLists.txt index e69c9e96c..91ab2d69f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16.3) # version on Ubuntu Focal -project(behaviortree_cpp VERSION 4.7.2 LANGUAGES C CXX) +project(behaviortree_cpp_picknik VERSION 4.7.2 LANGUAGES C CXX) # create compile_commands.json set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -188,7 +188,7 @@ target_link_libraries(${BTCPP_LIBRARY} target_include_directories(${BTCPP_LIBRARY} PUBLIC $ - $ + $ PRIVATE $ $ @@ -212,6 +212,15 @@ endif() add_library(BT::${BTCPP_LIBRARY} ALIAS ${BTCPP_LIBRARY}) +# A versioned soname (libbehaviortree_cpp_picknik.so..) makes a +# binary built against one ABI fail loudly at load time instead of silently +# binding to an incompatible library. Upstream ships an unversioned soname, +# which is what made the nav2 ABI mismatch in moveit_pro#20928 silently +# reachable. Minor-version bumps of this fork are treated as ABI breaks. +set_target_properties(${BTCPP_LIBRARY} PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) + # Add fuzzing targets if(ENABLE_FUZZING) add_fuzzing_targets() diff --git a/cmake/ament_build.cmake b/cmake/ament_build.cmake index ec1e0a66b..c9ef39511 100644 --- a/cmake/ament_build.cmake +++ b/cmake/ament_build.cmake @@ -24,7 +24,11 @@ set( BTCPP_EXTRA_LIBRARIES ament_export_dependencies(ament_index_cpp) set( BTCPP_LIB_DESTINATION lib ) -set( BTCPP_INCLUDE_DESTINATION include ) +# Headers install under a package-scoped root so this fork can coexist with +# upstream behaviortree_cpp on the same system (moveit_pro#20928). The exported +# include dir below points consumers at the scoped root, so source code keeps +# using #include "behaviortree_cpp/..." unchanged. +set( BTCPP_INCLUDE_DESTINATION include/${PROJECT_NAME} ) set( BTCPP_BIN_DESTINATION bin ) mark_as_advanced( @@ -35,7 +39,7 @@ mark_as_advanced( BTCPP_BIN_DESTINATION ) macro(export_btcpp_package) - ament_export_include_directories(include) + ament_export_include_directories(${BTCPP_INCLUDE_DESTINATION}) ament_export_libraries(${BTCPP_LIBRARY}) ament_export_targets(${BTCPP_LIBRARY}Targets) ament_package() diff --git a/include/behaviortree_cpp/basic_types.h b/include/behaviortree_cpp/basic_types.h index db63a7a79..cbca4c035 100644 --- a/include/behaviortree_cpp/basic_types.h +++ b/include/behaviortree_cpp/basic_types.h @@ -1,5 +1,12 @@ #pragma once +// Marks these headers as the PickNik fork (behaviortree_cpp_picknik). Stock +// upstream behaviortree_cpp coexists in the same image for nav2, and its +// unscoped headers could win include resolution in a misconfigured build — +// compiling fork consumers against the wrong ABI. Downstream code that +// requires the fork checks this macro and fails the compile loudly instead. +#define BTCPP_PICKNIK_FORK 1 + #include #include #include diff --git a/package.xml b/package.xml index e1d88e8b1..063ae64d9 100644 --- a/package.xml +++ b/package.xml @@ -1,6 +1,6 @@ - behaviortree_cpp + behaviortree_cpp_picknik 4.7.2 This package provides the Behavior Trees core library. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c00c5987b..6f50237de 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -49,10 +49,10 @@ else() find_package(GTest REQUIRED) enable_testing() - add_executable(behaviortree_cpp_test ${BT_TESTS}) - add_test(NAME btcpp_test COMMAND behaviortree_cpp_test) + add_executable(${BTCPP_LIBRARY}_test ${BT_TESTS}) + add_test(NAME btcpp_test COMMAND ${BTCPP_LIBRARY}_test) - target_link_libraries(behaviortree_cpp_test + target_link_libraries(${BTCPP_LIBRARY}_test GTest::gtest GTest::gtest_main GTest::gmock @@ -60,6 +60,6 @@ else() endif() -target_link_libraries(behaviortree_cpp_test ${BTCPP_LIBRARY} bt_sample_nodes foonathan::lexy) -target_include_directories(behaviortree_cpp_test PRIVATE include ${PROJECT_SOURCE_DIR}/3rdparty) -target_compile_definitions(behaviortree_cpp_test PRIVATE BT_TEST_FOLDER="${CMAKE_CURRENT_SOURCE_DIR}") +target_link_libraries(${BTCPP_LIBRARY}_test ${BTCPP_LIBRARY} bt_sample_nodes foonathan::lexy) +target_include_directories(${BTCPP_LIBRARY}_test PRIVATE include ${PROJECT_SOURCE_DIR}/3rdparty) +target_compile_definitions(${BTCPP_LIBRARY}_test PRIVATE BT_TEST_FOLDER="${CMAKE_CURRENT_SOURCE_DIR}")