From 4d2c7f116d5d70c516c0ca825c826acbf896af05 Mon Sep 17 00:00:00 2001 From: Peter LaValle Date: Tue, 22 Apr 2014 16:33:11 +0100 Subject: [PATCH 1/4] XML filename tweaks This change encodes the XML strings for scenarios involving `&` et al in material file names --- tools/assimp_cmd/WriteDumb.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/assimp_cmd/WriteDumb.cpp b/tools/assimp_cmd/WriteDumb.cpp index d33a83f64..669e71b3a 100644 --- a/tools/assimp_cmd/WriteDumb.cpp +++ b/tools/assimp_cmd/WriteDumb.cpp @@ -808,6 +808,27 @@ const char* TextureTypeToString(aiTextureType in) } +// ----------------------------------------------------------------------------------- +// Some chuncks of text will need to be encoded for XML +// http://stackoverflow.com/questions/5665231/most-efficient-way-to-escape-xml-html-in-c-string#5665377 +static std::string encodeXML(const std::string& data) { + std::string buffer; + buffer.reserve(data.size()); + for(size_t pos = 0; pos != data.size(); ++pos) { + switch(data[pos]) { + case '&': buffer.append("&"); break; + case '\"': buffer.append("""); break; + case '\'': buffer.append("'"); break; + case '<': buffer.append("<"); break; + case '>': buffer.append(">"); break; + default: buffer.append(&data[pos], 1); break; + } + } + return buffer; +} + + + // ----------------------------------------------------------------------------------- // Write a text model dump void WriteDump(const aiScene* scene, FILE* out, const char* src, const char* cmd, bool shortened) @@ -1014,7 +1035,7 @@ void WriteDump(const aiScene* scene, FILE* out, const char* src, const char* cmd } } else if (prop->mType == aiPTI_String) { - fprintf(out,">\n\t\t\t\"%s\"",prop->mData+4 /* skip length */); + fprintf(out,">\n\t\t\t\t\"%s\"",encodeXML(prop->mData+4).c_str() /* skip length */); } fprintf(out,"\n\t\t\t\n"); } From bd1d33e8e8b301167edb85d4d06f531b10fa1a38 Mon Sep 17 00:00:00 2001 From: YoheiKakiuchi Date: Wed, 23 Apr 2014 19:14:38 +0900 Subject: [PATCH 2/4] fix typo, BUILD_SHARED_LIBS --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec5820265..8b7250f5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,7 @@ SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH SET(ASSIMP_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfitx for lib, samples and tools") # Allow the user to build a static library -option ( BUILD_SHARED_LIB "Build a shared version of the library" ON ) +option ( BUILD_SHARED_LIBS "Build a shared version of the library" ON ) # Generate a pkg-config .pc for the Assimp library. CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/assimp.pc.in" "${PROJECT_BINARY_DIR}/assimp.pc" @ONLY ) From d4f25c0096c68645c72feb7b77c27e38c197763e Mon Sep 17 00:00:00 2001 From: xantares Date: Wed, 23 Apr 2014 14:12:10 +0200 Subject: [PATCH 3/4] Configure assimp-config.cmake.in after Boost is discovered as it requires the Boost version vars --- CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b7250f5b..7a760d2b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,11 +59,6 @@ option ( BUILD_SHARED_LIBS "Build a shared version of the library" ON ) CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/assimp.pc.in" "${PROJECT_BINARY_DIR}/assimp.pc" @ONLY ) INSTALL( FILES "${PROJECT_BINARY_DIR}/assimp.pc" DESTINATION ${ASSIMP_LIB_INSTALL_DIR}/pkgconfig/ COMPONENT ${LIBASSIMP-DEV_COMPONENT}) -# cmake configuration files -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT}) - # Only generate this target if no higher-level project already has IF (NOT TARGET uninstall) # add make uninstall capability @@ -95,6 +90,10 @@ ELSE ( ASSIMP_ENABLE_BOOST_WORKAROUND ) INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} ) ENDIF ( ASSIMP_ENABLE_BOOST_WORKAROUND ) +# cmake configuration files +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT}) SET ( ASSIMP_NO_EXPORT OFF CACHE BOOL "Disable Assimp's export functionality." From d49837819edbf5eab94293a6646783bab57e0a0c Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 26 Apr 2014 09:59:27 +0200 Subject: [PATCH 4/4] bugfix: remove WIN32-lookup for boost setup because these features are platform independent. Signed-off-by: Kim Kulling --- assimp-config.cmake.in | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/assimp-config.cmake.in b/assimp-config.cmake.in index e8b505cef..0cc380bd1 100644 --- a/assimp-config.cmake.in +++ b/assimp-config.cmake.in @@ -47,18 +47,16 @@ endif (CMAKE_BUILD_TYPE EQUAL "DEBUG") # the boost version assimp was compiled with set( ASSIMP_Boost_VERSION "@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@") -if( WIN32 ) - # search for the boost version assimp was compiled with - set(Boost_USE_MULTITHREAD ON) - set(Boost_USE_STATIC_LIBS OFF) - set(Boost_USE_STATIC_RUNTIME OFF) - find_package(Boost ${ASSIMP_Boost_VERSION} EXACT COMPONENTS thread date_time) - if(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") - set( ASSIMP_INCLUDE_DIRS "${ASSIMP_INCLUDE_DIRS}" ${Boost_INCLUDE_DIRS}) - else(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") - message(WARNING "Failed to find Boost ${ASSIMP_Boost_VERSION} necessary for assimp") - endif(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") -endif( WIN32 ) +# search for the boost version assimp was compiled with +set(Boost_USE_MULTITHREAD ON) +set(Boost_USE_STATIC_LIBS OFF) +set(Boost_USE_STATIC_RUNTIME OFF) +find_package(Boost ${ASSIMP_Boost_VERSION} EXACT COMPONENTS thread date_time) +if(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") + set( ASSIMP_INCLUDE_DIRS "${ASSIMP_INCLUDE_DIRS}" ${Boost_INCLUDE_DIRS}) +else(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") + message(WARNING "Failed to find Boost ${ASSIMP_Boost_VERSION} necessary for assimp") +endif(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") # for compatibility wiht pkg-config set(ASSIMP_CFLAGS_OTHER "${ASSIMP_CXX_FLAGS}")