Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ option(USE_VENDORED_FLATBUFFERS "Use the bundled version of flatbuffers" ON)
option(USE_VENDORED_LEXY "Use the bundled version of lexy" ON)
option(USE_VENDORED_MINICORO "Use the bundled version of minicoro" ON)
option(USE_VENDORED_MINITRACE "Use the bundled version of minitrace" ON)
option(USE_VENDORED_TINYXML2 "Use the bundled version of tinyxml2" ON)
# Usage of TINYXML2 sits with the ROS2 lookup

set(BTCPP_LIB_DESTINATION lib)
set(BTCPP_INCLUDE_DESTINATION include)
Expand Down Expand Up @@ -84,6 +84,7 @@ if(POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
endif()

set(_default_use_vendored_tiny_xml ON)
find_package(ament_cmake QUIET)

if ( ament_cmake_FOUND )
Expand All @@ -93,12 +94,14 @@ if ( ament_cmake_FOUND )
message(STATUS "BehaviorTree is being built using AMENT.")
message(STATUS "------------------------------------------")
include(cmake/ament_build.cmake)
set(_default_use_vendored_tiny_xml OFF)
else()
message(STATUS "------------------------------------------")
message(STATUS "BehaviorTree is being built without AMENT.")
message(STATUS "------------------------------------------")
include(cmake/conan_build.cmake)
endif()
option(USE_VENDORED_TINYXML2 "Use the bundled version of tinyxml2" ${_default_use_vendored_tiny_xml})
Copy link
Contributor

@ericriff ericriff Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could leave the option declaration above with the rest and on line 97 use a combination of set + force to disable it.
That way all related options are still on the same place.

Another possible approach is to move up the find ament call so it happens before we declare the options and then do something like `set(AMENT_MODE ament_cmake_FOUND)
And use that as the default value for the tinyxml option

option(USE_VENDORED_TINYXML2 "Use the bundled version of tinyxml2" ${AMENT_MODE})

The rationale is the same, keep all the options to opt out of vendored dependencies together

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried playing around with something like the first option, but the cached option didn't behave the way I expected. I am only a ROS user and I wasn't sure how to make the change without potentially breaking someone else's workflow by always force overriding a cached thing.

Open to doing the second thing. It is the way it is to minimise the line diff. If the logic is acceptable I will squash the commits and reorder to move the option back to the same spot as the others.


#############################################################
# Handle dependencies
Expand Down Expand Up @@ -144,7 +147,12 @@ endif()
if(USE_VENDORED_TINYXML2)
add_subdirectory(3rdparty/tinyxml2)
else()
find_package(tinyxml2 REQUIRED)
if(ament_cmake_FOUND)
find_package(tinyxml2_vendor REQUIRED)
find_package(TinyXML2 REQUIRED)
else()
find_package(tinyxml2 REQUIRED)
endif()
endif()

list(APPEND BT_SOURCE
Expand Down
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

<depend>libsqlite3-dev</depend>
<depend>libzmq3-dev</depend>
<depend>tinyxml2</depend>
<depend>tinyxml2_vendor</depend>

<test_depend >ament_cmake_gtest</test_depend>

Expand Down
Loading