Skip to content

Commit e82053f

Browse files
committed
CMake: prefer system tinyxml2, fix #1014
1 parent c0bc00b commit e82053f

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed
File renamed without changes.
File renamed without changes.

CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ endif()
6464

6565
#---- Find other packages ----
6666
find_package(Threads REQUIRED)
67+
find_package(tinyxml2 CONFIG)
6768

6869

6970
set(BEHAVIOR_TREE_LIBRARY ${PROJECT_NAME})
@@ -141,10 +142,11 @@ list(APPEND BT_SOURCE
141142
src/loggers/bt_file_logger_v2.cpp
142143
src/loggers/bt_minitrace_logger.cpp
143144
src/loggers/bt_observer.cpp
144-
145-
3rdparty/tinyxml2/tinyxml2.cpp
146145
)
147146

147+
if(NOT TARGET tinyxml2::tinyxml2)
148+
list(APPEND BT_SOURCE 3rdparty/tinyxml2/src/tinyxml2.cpp)
149+
endif()
148150

149151
if(BTCPP_GROOT_INTERFACE)
150152
# should be found already, at this stage
@@ -186,6 +188,15 @@ target_link_libraries(${BTCPP_LIBRARY}
186188
${BTCPP_EXTRA_LIBRARIES}
187189
)
188190

191+
if(TARGET tinyxml2::tinyxml2)
192+
target_link_libraries(${BTCPP_LIBRARY} PRIVATE tinyxml2::tinyxml2)
193+
else()
194+
target_include_directories(${BTCPP_LIBRARY} PRIVATE
195+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/tinyxml2/include>
196+
)
197+
endif()
198+
199+
189200
target_include_directories(${BTCPP_LIBRARY}
190201
PUBLIC
191202
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>

src/xml_parsing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#include <map>
3535
#include "behaviortree_cpp/xml_parsing.h"
36-
#include "tinyxml2/tinyxml2.h"
36+
#include "tinyxml2.h"
3737
#include <filesystem>
3838

3939
#ifdef USING_ROS2

0 commit comments

Comments
 (0)