Skip to content

Commit

Permalink
Merge branch 'main' into jrivero/fix_hidden_visibility_win
Browse files Browse the repository at this point in the history
  • Loading branch information
mjcarroll authored Nov 10, 2023
2 parents 097ee0b + 09491f5 commit 6d81bba
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 4,680 deletions.
21 changes: 4 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ if(WIN32)
false)
endif()

#--------------------------------------
# Option: Should we use our internal copy of tinyxml2?
if(UNIX OR APPLE)
option(USE_EXTERNAL_TINYXML2 "Use a system-installed version of tinyxml2" ON)
elseif(WIN32)
# For backward compatibility, this option on Windows by default is OFF
option(USE_EXTERNAL_TINYXML2 "Use a system-installed version of tinyxml2" OFF)
endif()


#============================================================================
# Search for project-specific dependencies
#============================================================================
Expand All @@ -59,13 +49,10 @@ set(GZ_UTILS_VER ${gz-utils3_VERSION_MAJOR})

#--------------------------------------
# Find Tinyxml2
if(USE_EXTERNAL_TINYXML2)
gz_find_package(TINYXML2 PRETTY tinyxml2
REQUIRED_BY graphics
PRIVATE_FOR graphics)
else()
message(STATUS "Skipping search for tinyxml2 and using an internal version\n")
endif()
gz_find_package(TINYXML2 PRETTY tinyxml2
VERSION 6.0
REQUIRED_BY graphics
PRIVATE_FOR graphics)

#--------------------------------------
# Find dependencies that we ignore for Visual Studio
Expand Down
60 changes: 4 additions & 56 deletions graphics/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
gz_get_libsources_and_unittests(sources gtest_sources)


if(NOT USE_EXTERNAL_TINYXML2)
# If we are using our internal copy of tinyxml2, then add its
# source file.
message(STATUS "Adding tinyxml2 source files")
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/tinyxml2/tinyxml2.cpp)
endif()


gz_add_component(graphics SOURCES ${sources} GET_TARGET_NAME graphics_target)

target_link_libraries(${graphics_target}
Expand All @@ -18,14 +9,17 @@ target_link_libraries(${graphics_target}
PRIVATE
${GzAssimp_LIBRARIES}
GTS::GTS
FreeImage::FreeImage)
FreeImage::FreeImage
TINYXML2::TINYXML2
)

gz_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
LIB_DEPS
${graphics_target}
gz-common${GZ_COMMON_VER}-testing
TINYXML2::TINYXML2
)

# Assimp doesn't offer preprocessor version, use cmake to set a compatibility
Expand All @@ -37,49 +31,3 @@ if(${GzAssimp_VERSION} STRLESS "5.2.0")
target_compile_definitions(UNIT_AssimpLoader_TEST PRIVATE GZ_ASSIMP_PRE_5_2_0)
endif()
endif()


if(USE_EXTERNAL_TINYXML2)

# If we are using an external copy of tinyxml2, add its imported target
target_link_libraries(${graphics_target}
PRIVATE
TINYXML2::TINYXML2)

# The collada exporter test uses tinyxml2, so we must link it if we're using
# an external copy. The graphics target considers tinyxml2 to be a private
# dependency, so it will not automatically get linked to this test.
if(TARGET UNIT_ColladaExporter_TEST)
target_link_libraries(UNIT_ColladaExporter_TEST TINYXML2::TINYXML2)
endif()

else()

# Otherwise, add its source directory to our target's PRIVATE include
# directories. We do not want this to be visible to consumers of
# gz-common.
target_include_directories(${graphics_target}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tinyxml2)

if(TARGET UNIT_ColladaExporter_TEST)

# If we are using the internal copy of tinyxml2, then the collada exporter
# test needs to be pointed to the internal tinyxml2 include directory.
target_include_directories(UNIT_ColladaExporter_TEST PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tinyxml2)
# We also need to add this as a source file to the collada exporter test's
# target, because we do not export the tinyxml2 symbols that get generated
# in the gz-common library. Therefore, the collada exporter test
# cannot link to those symbols and must generate its own.
target_sources(UNIT_ColladaExporter_TEST PRIVATE tinyxml2/tinyxml2.cpp)

endif()

endif()

# define of tinxml2 major version >= 6
# https://github.com/gazebosim/gz-common/issues/28
if (NOT TINYXML2_VERSION VERSION_LESS "6.0.0")
message(STATUS "TINYXML2_VERSION ${TINYXML2_VERSION} >= 6.0.0")
target_compile_definitions(${graphics_target}
PRIVATE "TINYXML2_MAJOR_VERSION_GE_6")
endif()
20 changes: 0 additions & 20 deletions graphics/src/ColladaExporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@

#include "tinyxml2.h"

#ifndef TINYXML2_MAJOR_VERSION_GE_6
#if TINYXML2_MAJOR_VERSION >= 6
#define TINYXML2_MAJOR_VERSION_GE_6
#endif
#endif

#ifdef _WIN32
static const char pathSeparator = '\\';
#define snprintf _snprintf
Expand All @@ -50,24 +44,10 @@ static void LogTinyXml2DocumentError(
{
warning += std::to_string(_doc.ErrorID()) + "): ";

#ifdef TINYXML2_MAJOR_VERSION_GE_6
const char * error1 = _doc.ErrorStr();
#else
const char * error1 = _doc.GetErrorStr1();
#endif

if (error1)
warning += "str1=" + std::string(error1);

#ifndef TINYXML2_MAJOR_VERSION_GE_6
const char * error2 = _doc.GetErrorStr2();

if (error1 && error2)
warning += ", ";

if (error2)
warning += "str2=" + std::string(error2);
#endif
}
else
{
Expand Down
18 changes: 2 additions & 16 deletions graphics/src/SVGLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@

#include "tinyxml2.h"

#ifndef TINYXML2_MAJOR_VERSION_GE_6
#if TINYXML2_MAJOR_VERSION >= 6
#define TINYXML2_MAJOR_VERSION_GE_6
#endif
#endif

#include "gz/common/Console.hh"
#include "gz/common/Util.hh"

Expand Down Expand Up @@ -885,20 +879,12 @@ bool SVGLoader::Parse(const std::string &_filename,
tinyxml2::XMLDocument doc;
if (doc.LoadFile(_filename.c_str()) != tinyxml2::XML_SUCCESS)
{
#ifdef TINYXML2_MAJOR_VERSION_GE_6
const char *str1 = doc.ErrorStr();
const char *str2 = nullptr;
#else
const char *str1 = doc.GetErrorStr1();
const char *str2 = doc.GetErrorStr2();
#endif
std::string err1 = str1 ? str1 : "n/a";
std::string err2 = str2 ? str2 : "n/a";
std::string err1 = str1 != nullptr ? str1 : "n/a";

gzerr << "Failed to load file " << _filename << std::endl
<< "XML error type " << doc.ErrorName() << "\n"
<< "XML error info 1 " << err1 << "\n"
<< "XML error info 2 " << err2 << "\n";
<< "XML error info 1 " << err1 << "\n";
return false;
}

Expand Down
1 change: 0 additions & 1 deletion graphics/src/tinyxml2/VERSION_3.0.0

This file was deleted.

Loading

0 comments on commit 6d81bba

Please sign in to comment.