From 1b37b74f9e95844a4603623335378c5e87bb23e7 Mon Sep 17 00:00:00 2001 From: Rahul Sheth Date: Wed, 7 Jul 2021 17:01:19 -0400 Subject: [PATCH] Hunter fixes for stb_image --- CMakeLists.txt | 5 ++--- code/AssetLib/M3D/M3DWrapper.h | 2 +- code/CMakeLists.txt | 19 ++++++++++++++++--- code/Common/Assimp.cpp | 2 +- code/Pbrt/PbrtExporter.cpp | 2 +- contrib/{stb_image => stb}/stb_image.h | 0 6 files changed, 21 insertions(+), 9 deletions(-) rename contrib/{stb_image => stb}/stb_image.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc1366a1a..2dfe592bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,8 +46,8 @@ option(ASSIMP_HUNTER_ENABLED "Enable Hunter package manager support" OFF) IF(ASSIMP_HUNTER_ENABLED) include("cmake/HunterGate.cmake") HunterGate( - URL "https://github.com/cpp-pm/hunter/archive/v0.23.293.tar.gz" - SHA1 "e8e5470652db77149d9b38656db2a6c0b7642693" + URL "https://github.com/cpp-pm/hunter/archive/v0.23.311.tar.gz" + SHA1 "1a82b9b73055879181cb1466b2ab5d48ee8ae410" ) add_definitions(-DASSIMP_USE_HUNTER) @@ -227,7 +227,6 @@ INCLUDE_DIRECTORIES( BEFORE include ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/include - contrib/ ) LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules" ) diff --git a/code/AssetLib/M3D/M3DWrapper.h b/code/AssetLib/M3D/M3DWrapper.h index b5d1785b2..54d7a2eec 100644 --- a/code/AssetLib/M3D/M3DWrapper.h +++ b/code/AssetLib/M3D/M3DWrapper.h @@ -57,7 +57,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Share stb_image's PNG loader with other importers/exporters instead of bringing our own copy. #define STBI_ONLY_PNG -#include +#include #include "m3d.h" diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index fe4abc06f..fd92d41e3 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -873,6 +873,7 @@ ELSE() ../contrib/pugixml/src/pugiconfig.hpp ../contrib/pugixml/src/pugixml.hpp ) + INCLUDE_DIRECTORIES("../contrib/pugixml/src") SOURCE_GROUP( Contrib\\Pugixml FILES ${Pugixml_SRCS}) ENDIF() @@ -1034,8 +1035,6 @@ IF(ASSIMP_HUNTER_ENABLED) find_package(RapidJSON CONFIG REQUIRED) ELSE() INCLUDE_DIRECTORIES("../contrib/rapidjson/include") - INCLUDE_DIRECTORIES( "../contrib" ) - INCLUDE_DIRECTORIES("../contrib/pugixml/src") ADD_DEFINITIONS( -DRAPIDJSON_HAS_STDSTRING=1) option( ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR "Suppress rapidjson warning on MSVC (NOTE: breaks android build)" ON ) if(ASSIMP_RAPIDJSON_NO_MEMBER_ITERATOR) @@ -1043,6 +1042,18 @@ ELSE() endif() ENDIF() +# stb +IF(ASSIMP_HUNTER_ENABLED) + hunter_add_package(stb) + find_package(stb CONFIG REQUIRED) +ELSE() + SET( stb_SRCS + ../contrib/stb/stb_image.h + ) + INCLUDE_DIRECTORIES("../contrib") + SOURCE_GROUP( Contrib\\stb FILES ${stb_SRCS}) +ENDIF() + # VC2010 fixes if(MSVC10) option( VC10_STDINT_FIX "Fix for VC10 Compiler regarding pstdint.h redefinition errors" OFF ) @@ -1101,6 +1112,7 @@ SET( assimp_src ${open3dgc_SRCS} ${ziplib_SRCS} ${Pugixml_SRCS} + ${stb_SRCS} # Necessary to show the headers in the project when using the VC++ generator: ${PUBLIC_HEADERS} @@ -1158,8 +1170,9 @@ IF(ASSIMP_HUNTER_ENABLED) utf8cpp zip::zip pugixml + stb::stb ) - + if (ASSIMP_BUILD_DRACO) target_link_libraries(assimp PUBLIC ${draco_LIBRARIES}) endif() diff --git a/code/Common/Assimp.cpp b/code/Common/Assimp.cpp index a6c539bca..ca0912979 100644 --- a/code/Common/Assimp.cpp +++ b/code/Common/Assimp.cpp @@ -1277,7 +1277,7 @@ ASSIMP_API void aiQuaternionInterpolate( # endif # define STB_IMAGE_IMPLEMENTATION -# include "stb_image/stb_image.h" +# include "stb/stb_image.h" # if _MSC_VER # pragma warning(pop) diff --git a/code/Pbrt/PbrtExporter.cpp b/code/Pbrt/PbrtExporter.cpp index 260d90322..1c7024c28 100644 --- a/code/Pbrt/PbrtExporter.cpp +++ b/code/Pbrt/PbrtExporter.cpp @@ -83,7 +83,7 @@ Other: #include #include -#include "../contrib/stb_image/stb_image.h" +#include "stb/stb_image.h" using namespace Assimp; diff --git a/contrib/stb_image/stb_image.h b/contrib/stb/stb_image.h similarity index 100% rename from contrib/stb_image/stb_image.h rename to contrib/stb/stb_image.h