Skip to content

Commit

Permalink
Support new ErrorStr API in tinyxml2 6.0.0 (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 authored Jan 6, 2018
1 parent 0f945b9 commit b466493
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

* Added WorldInteractiveMarkerViewer: [#242](https://github.com/personalrobotics/aikido/pull/242)

* IO

* Added support for new ErrorStr API in tinyxml2 6.0.0: [#290](https://github.com/personalrobotics/aikido/pull/290)

* Build & Testing & ETC

* Changed to use size_t over std::size_t: [#230](https://github.com/personalrobotics/aikido/pull/230)
Expand Down
46 changes: 38 additions & 8 deletions cmake/FindTinyXML2.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
# Copyright (c) 2014 Andrew Kelley
# This file is MIT licensed.
# See http://opensource.org/licenses/MIT
# Copyright (c) 2011-2017, The DART development contributors
# All rights reserved.
#
# The list of contributors can be found at:
# https://github.com/dartsim/dart/blob/master/LICENSE
#
# This file is provided under the "BSD-style" License

# Find TinyXML2
#
# This sets the following variables:
# TinyXML2_FOUND
# TinyXML2_INCLUDE_DIRS
# TinyXML2_LIBRARIES
# TinyXML2_VERSION

find_path(TinyXML2_INCLUDE_DIRS NAMES tinyxml2.h)
find_library(TinyXML2_LIBRARIES NAMES tinyxml2)
find_package(PkgConfig QUIET)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(TinyXML2 DEFAULT_MSG TinyXML2_LIBRARIES TinyXML2_INCLUDE_DIRS)
# Check if the pkgconfig file is installed
pkg_check_modules(PC_TINYXML2 tinyxml2 QUIET)

# Include directories
find_path(TinyXML2_INCLUDE_DIRS
NAMES tinyxml2.h
HINTS ${PC_TinyXML2_INCLUDEDIR}
PATHS "${CMAKE_INSTALL_PREFIX}/include")

# Libraries
if(MSVC)
set(TinyXML2_LIBRARIES optimized tinyxml2 debug tinyxml2d)
else()
find_library(TinyXML2_LIBRARIES
NAMES tinyxml2
HINTS ${PC_TinyXML2_LIBDIR})
endif()

mark_as_advanced(TinyXML2_INCLUDE_DIRS TinyXML2_LIBRARIES)
# Version
set(TinyXML2_VERSION ${PC_TINYXML2_VERSION})

# Set (NAME)_FOUND if all the variables and the version are satisfied.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(TinyXML2
FAIL_MESSAGE DEFAULT_MSG
REQUIRED_VARS TinyXML2_INCLUDE_DIRS TinyXML2_LIBRARIES
VERSION_VAR TinyXML2_VERSION)
7 changes: 7 additions & 0 deletions src/io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ if(YAMLCPP_NODE_HAS_MARK)
PUBLIC YAMLCPP_NODE_HAS_MARK)
endif()

# Define TINYXML2_MAJOR_VERSION_GE_6 to support API breaking changes of
# tinyxml2 6
if (NOT TINYXML2_VERSION VERSION_LESS "6.0.0")
target_compile_definitions("${PROJECT_NAME}_io"
PRIVATE "TINYXML2_MAJOR_VERSION_GE_6")
endif()

add_component(${PROJECT_NAME} io)
add_component_targets(${PROJECT_NAME} io "${PROJECT_NAME}_io")
add_component_dependencies(${PROJECT_NAME} io common)
Expand Down
6 changes: 5 additions & 1 deletion src/io/CatkinResourceRetriever.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <aikido/io/CatkinResourceRetriever.hpp>
#include "aikido/io/CatkinResourceRetriever.hpp"

#include <fstream>
#include <iostream>
Expand Down Expand Up @@ -27,7 +27,11 @@ std::string getPackageNameFromXML(const std::string& _path)
if (document.LoadFile(_path.c_str()))
{
dtwarn << "[CatkinResourceRetriever] Failed loading package.xml file '"
#ifdef TINYXML2_MAJOR_VERSION_GE_6
<< _path << "': " << document.ErrorStr() << "\n";
#else
<< _path << "': " << document.GetErrorStr1() << "\n";
#endif
return "";
}

Expand Down

0 comments on commit b466493

Please sign in to comment.