Skip to content

Commit d758e29

Browse files
committed
CMake: prefer system tinyxml2
1 parent d8c1609 commit d758e29

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed
File renamed without changes.

3rdparty/tinyxml2/tinyxml2.cpp renamed to 3rdparty/tinyxml2/src/tinyxml2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ must not be misrepresented as being the original software.
2121
distribution.
2222
*/
2323

24-
#include "tinyxml2.h"
24+
#include "tinyxml2/tinyxml2.h"
2525

2626
#include <new> // yes, this one new style header, is in the Android SDK.
2727
#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)

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)
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 tinyxml2_FOUND)
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(tinyxml2_FOUND)
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>

0 commit comments

Comments
 (0)