Use hunter to download dependencies if HUNTER_ENABLED is ON

pull/2488/head
Rahul Sheth 2019-05-24 16:13:55 -04:00 committed by Rahul Sheth
parent 1db3e1e11f
commit a4587e8609
3 changed files with 237 additions and 149 deletions

View File

@ -34,8 +34,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#---------------------------------------------------------------------- #----------------------------------------------------------------------
SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required CMAKE_MINIMUM_REQUIRED( VERSION 3.0 )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
# Toggles the use of the hunter package manager # Toggles the use of the hunter package manager
option(HUNTER_ENABLED "Enable Hunter package manager support" OFF) option(HUNTER_ENABLED "Enable Hunter package manager support" OFF)
@ -386,11 +385,20 @@ ENDIF( SYSTEM_IRRXML )
# Search for external dependencies, and build them from source if not found # Search for external dependencies, and build them from source if not found
# Search for zlib # Search for zlib
IF ( NOT ASSIMP_BUILD_ZLIB ) IF(HUNTER_ENABLED)
FIND_PACKAGE(ZLIB) hunter_add_package(ZLIB)
ENDIF( NOT ASSIMP_BUILD_ZLIB ) find_package(ZLIB CONFIG REQUIRED)
IF( NOT ZLIB_FOUND ) add_definitions(-DASSIMP_BUILD_NO_OWN_ZLIB)
set(ZLIB_FOUND TRUE)
set(ZLIB_LIBRARIES ZLIB::zlib)
set(ASSIMP_BUILD_MINIZIP TRUE)
ELSE(HUNTER_ENABLED)
IF ( NOT ASSIMP_BUILD_ZLIB )
FIND_PACKAGE(ZLIB)
ENDIF( NOT ASSIMP_BUILD_ZLIB )
IF( NOT ZLIB_FOUND )
MESSAGE(STATUS "compiling zlib from sources") MESSAGE(STATUS "compiling zlib from sources")
INCLUDE(CheckIncludeFile) INCLUDE(CheckIncludeFile)
INCLUDE(CheckTypeSize) INCLUDE(CheckTypeSize)
@ -411,23 +419,23 @@ IF( NOT ZLIB_FOUND )
SET(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/contrib/zlib ${CMAKE_CURRENT_BINARY_DIR}/contrib/zlib) SET(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/contrib/zlib ${CMAKE_CURRENT_BINARY_DIR}/contrib/zlib)
# need to ensure we don't link with system zlib or minizip as well. # need to ensure we don't link with system zlib or minizip as well.
SET(ASSIMP_BUILD_MINIZIP 1) SET(ASSIMP_BUILD_MINIZIP 1)
ELSE(NOT ZLIB_FOUND) ELSE(NOT ZLIB_FOUND)
ADD_DEFINITIONS(-DASSIMP_BUILD_NO_OWN_ZLIB) ADD_DEFINITIONS(-DASSIMP_BUILD_NO_OWN_ZLIB)
SET(ZLIB_LIBRARIES_LINKED -lz) SET(ZLIB_LIBRARIES_LINKED -lz)
ENDIF(NOT ZLIB_FOUND) ENDIF(NOT ZLIB_FOUND)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
ENDIF(HUNTER_ENABLED)
# Search for unzip IF( NOT IOS )
IF ( NOT IOS )
IF( NOT ASSIMP_BUILD_MINIZIP ) IF( NOT ASSIMP_BUILD_MINIZIP )
use_pkgconfig(UNZIP minizip) use_pkgconfig(UNZIP minizip)
ENDIF( NOT ASSIMP_BUILD_MINIZIP ) ENDIF( NOT ASSIMP_BUILD_MINIZIP )
ELSE ( NOT IOS ) ELSE ( NOT IOS )
IF(NOT BUILD_SHARED_LIBS) IF( NOT BUILD_SHARED_LIBS )
IF( NOT ASSIMP_BUILD_MINIZIP ) IF( NOT ASSIMP_BUILD_MINIZIP )
use_pkgconfig(UNZIP minizip) use_pkgconfig(UNZIP minizip)
ENDIF( NOT ASSIMP_BUILD_MINIZIP ) ENDIF( NOT ASSIMP_BUILD_MINIZIP )
ENDIF (NOT BUILD_SHARED_LIBS) ENDIF ( NOT BUILD_SHARED_LIBS )
ENDIF ( NOT IOS ) ENDIF ( NOT IOS )
IF ( ASSIMP_NO_EXPORT ) IF ( ASSIMP_NO_EXPORT )
@ -501,7 +509,9 @@ ELSE (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
ADD_DEFINITIONS( -DASSIMP_BUILD_NO_C4D_IMPORTER ) ADD_DEFINITIONS( -DASSIMP_BUILD_NO_C4D_IMPORTER )
ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER) ENDIF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
ADD_SUBDIRECTORY(contrib) IF(NOT HUNTER_ENABLED)
ADD_SUBDIRECTORY(contrib)
ENDIF(NOT HUNTER_ENABLED)
ADD_SUBDIRECTORY( code/ ) ADD_SUBDIRECTORY( code/ )
IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) IF ( ASSIMP_BUILD_ASSIMP_TOOLS )

View File

@ -43,7 +43,7 @@
# 3) Add libassimp using the file lists (eliminates duplication of file names between # 3) Add libassimp using the file lists (eliminates duplication of file names between
# source groups and library command) # source groups and library command)
# #
cmake_minimum_required( VERSION 2.6 ) cmake_minimum_required( VERSION 3.0 )
SET( HEADER_PATH ../include/assimp ) SET( HEADER_PATH ../include/assimp )
if(NOT ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM) if(NOT ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)
@ -848,13 +848,40 @@ SET( Extra_SRCS
) )
SOURCE_GROUP( Extra FILES ${Extra_SRCS}) SOURCE_GROUP( Extra FILES ${Extra_SRCS})
SET( Clipper_SRCS # irrXML
IF(HUNTER_ENABLED)
hunter_add_package(irrXML)
find_package(irrXML CONFIG REQUIRED)
ELSE(HUNTER_ENABLED)
# irrXML already included in contrib directory by parent CMakeLists.txt.
ENDIF(HUNTER_ENABLED)
# utf8
IF(HUNTER_ENABLED)
hunter_add_package(utf8)
find_package(utf8 CONFIG REQUIRED)
ELSE(HUNTER_ENABLED)
# utf8 is header-only, so Assimp doesn't need to do anything.
ENDIF(HUNTER_ENABLED)
# polyclipping
IF(HUNTER_ENABLED)
hunter_add_package(polyclipping)
find_package(polyclipping CONFIG REQUIRED)
ELSE(HUNTER_ENABLED)
SET( Clipper_SRCS
../contrib/clipper/clipper.hpp ../contrib/clipper/clipper.hpp
../contrib/clipper/clipper.cpp ../contrib/clipper/clipper.cpp
) )
SOURCE_GROUP( Contrib\\Clipper FILES ${Clipper_SRCS}) SOURCE_GROUP( Contrib\\Clipper FILES ${Clipper_SRCS})
ENDIF(HUNTER_ENABLED)
SET( Poly2Tri_SRCS # poly2tri
IF(HUNTER_ENABLED)
hunter_add_package(poly2tri)
find_package(poly2tri CONFIG REQUIRED)
ELSE(HUNTER_ENABLED)
SET( Poly2Tri_SRCS
../contrib/poly2tri/poly2tri/common/shapes.cc ../contrib/poly2tri/poly2tri/common/shapes.cc
../contrib/poly2tri/poly2tri/common/shapes.h ../contrib/poly2tri/poly2tri/common/shapes.h
../contrib/poly2tri/poly2tri/common/utils.h ../contrib/poly2tri/poly2tri/common/utils.h
@ -866,34 +893,52 @@ SET( Poly2Tri_SRCS
../contrib/poly2tri/poly2tri/sweep/sweep.h ../contrib/poly2tri/poly2tri/sweep/sweep.h
../contrib/poly2tri/poly2tri/sweep/sweep_context.cc ../contrib/poly2tri/poly2tri/sweep/sweep_context.cc
../contrib/poly2tri/poly2tri/sweep/sweep_context.h ../contrib/poly2tri/poly2tri/sweep/sweep_context.h
) )
SOURCE_GROUP( Contrib\\Poly2Tri FILES ${Poly2Tri_SRCS}) SOURCE_GROUP( Contrib\\Poly2Tri FILES ${Poly2Tri_SRCS})
ENDIF(HUNTER_ENABLED)
SET( unzip_SRCS # minizip/unzip
IF(HUNTER_ENABLED)
hunter_add_package(minizip)
find_package(minizip CONFIG REQUIRED)
ELSE(HUNTER_ENABLED)
SET( unzip_SRCS
../contrib/unzip/crypt.h ../contrib/unzip/crypt.h
../contrib/unzip/ioapi.c ../contrib/unzip/ioapi.c
../contrib/unzip/ioapi.h ../contrib/unzip/ioapi.h
../contrib/unzip/unzip.c ../contrib/unzip/unzip.c
../contrib/unzip/unzip.h ../contrib/unzip/unzip.h
) )
SOURCE_GROUP(Contrib\\unzip FILES ${unzip_SRCS}) SOURCE_GROUP(Contrib\\unzip FILES ${unzip_SRCS})
ENDIF(HUNTER_ENABLED)
SET( ziplib_SRCS # zip (https://github.com/kuba--/zip)
IF(HUNTER_ENABLED)
hunter_add_package(zip)
find_package(zip CONFIG REQUIRED)
ELSE(HUNTER_ENABLED)
SET( ziplib_SRCS
../contrib/zip/src/miniz.h ../contrib/zip/src/miniz.h
../contrib/zip/src/zip.c ../contrib/zip/src/zip.c
../contrib/zip/src/zip.h ../contrib/zip/src/zip.h
) )
# TODO if cmake required version has been updated to >3.12.0, collapse this to the second case only # TODO if cmake required version has been updated to >3.12.0, collapse this to the second case only
if(${CMAKE_VERSION} VERSION_LESS "3.12.0") if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
add_definitions(-DMINIZ_USE_UNALIGNED_LOADS_AND_STORES=0) add_definitions(-DMINIZ_USE_UNALIGNED_LOADS_AND_STORES=0)
else() else()
add_compile_definitions(MINIZ_USE_UNALIGNED_LOADS_AND_STORES=0) add_compile_definitions(MINIZ_USE_UNALIGNED_LOADS_AND_STORES=0)
endif() endif()
SOURCE_GROUP( ziplib FILES ${ziplib_SRCS} ) SOURCE_GROUP( ziplib FILES ${ziplib_SRCS} )
ENDIF(HUNTER_ENABLED)
SET ( openddl_parser_SRCS # openddlparser
IF(HUNTER_ENABLED)
hunter_add_package(openddlparser)
find_package(openddlparser CONFIG REQUIRED)
ELSE(HUNTER_ENABLED)
SET ( openddl_parser_SRCS
../contrib/openddlparser/code/OpenDDLParser.cpp ../contrib/openddlparser/code/OpenDDLParser.cpp
../contrib/openddlparser/code/DDLNode.cpp ../contrib/openddlparser/code/DDLNode.cpp
../contrib/openddlparser/code/OpenDDLCommon.cpp ../contrib/openddlparser/code/OpenDDLCommon.cpp
@ -907,10 +952,15 @@ SET ( openddl_parser_SRCS
../contrib/openddlparser/include/openddlparser/OpenDDLStream.h ../contrib/openddlparser/include/openddlparser/OpenDDLStream.h
../contrib/openddlparser/include/openddlparser/DDLNode.h ../contrib/openddlparser/include/openddlparser/DDLNode.h
../contrib/openddlparser/include/openddlparser/Value.h ../contrib/openddlparser/include/openddlparser/Value.h
) )
SOURCE_GROUP( Contrib\\openddl_parser FILES ${openddl_parser_SRCS}) SOURCE_GROUP( Contrib\\openddl_parser FILES ${openddl_parser_SRCS})
ENDIF(HUNTER_ENABLED)
SET ( open3dgc_SRCS # Open3DGC
IF(HUNTER_ENABLED)
# Nothing to do, not available in Hunter yet.
ELSE(HUNTER_ENABLED)
SET ( open3dgc_SRCS
../contrib/Open3DGC/o3dgcAdjacencyInfo.h ../contrib/Open3DGC/o3dgcAdjacencyInfo.h
../contrib/Open3DGC/o3dgcArithmeticCodec.cpp ../contrib/Open3DGC/o3dgcArithmeticCodec.cpp
../contrib/Open3DGC/o3dgcArithmeticCodec.h ../contrib/Open3DGC/o3dgcArithmeticCodec.h
@ -940,24 +990,31 @@ SET ( open3dgc_SRCS
../contrib/Open3DGC/o3dgcTriangleListEncoder.inl ../contrib/Open3DGC/o3dgcTriangleListEncoder.inl
../contrib/Open3DGC/o3dgcVector.h ../contrib/Open3DGC/o3dgcVector.h
../contrib/Open3DGC/o3dgcVector.inl ../contrib/Open3DGC/o3dgcVector.inl
) )
SOURCE_GROUP( Contrib\\open3dgc FILES ${open3dgc_SRCS}) SOURCE_GROUP( Contrib\\open3dgc FILES ${open3dgc_SRCS})
ENDIF(HUNTER_ENABLED)
# Check dependencies for glTF importer with Open3DGC-compression. # Check dependencies for glTF importer with Open3DGC-compression.
# RT-extensions is used in "contrib/Open3DGC/o3dgcTimer.h" for collecting statistics. Pointed file # RT-extensions is used in "contrib/Open3DGC/o3dgcTimer.h" for collecting statistics. Pointed file
# has implementation for different platforms: WIN32, __MACH__ and other ("else" block). # has implementation for different platforms: WIN32, __MACH__ and other ("else" block).
FIND_PACKAGE(RT QUIET) FIND_PACKAGE(RT QUIET)
IF (RT_FOUND OR MSVC) IF (NOT HUNTER_ENABLED AND (RT_FOUND OR MSVC))
SET( ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC 1 ) SET( ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC 1 )
ADD_DEFINITIONS( -DASSIMP_IMPORTER_GLTF_USE_OPEN3DGC=1 ) ADD_DEFINITIONS( -DASSIMP_IMPORTER_GLTF_USE_OPEN3DGC=1 )
ELSE () ELSE ()
SET (open3dgc_SRCS "") SET (open3dgc_SRCS "")
MESSAGE (INFO " RT-extension not found. glTF import/export will be built without Open3DGC-compression.") MESSAGE (INFO " Hunter enabled or RT-extension not found. glTF import/export will be built without Open3DGC-compression.")
#!TODO: off course is better to remove statistics timers from o3dgc codec. Or propose to choose what to use. #!TODO: off course is better to remove statistics timers from o3dgc codec. Or propose to choose what to use.
ENDIF () ENDIF ()
INCLUDE_DIRECTORIES( "../contrib/rapidjson/include" ) # RapidJSON
INCLUDE_DIRECTORIES( "../contrib" ) IF(HUNTER_ENABLED)
hunter_add_package(RapidJSON)
find_package(RapidJSON CONFIG REQUIRED)
ELSE(HUNTER_ENABLED)
INCLUDE_DIRECTORIES( "../contrib/rapidjson/include" )
INCLUDE_DIRECTORIES( "../contrib" )
ENDIF(HUNTER_ENABLED)
# VC2010 fixes # VC2010 fixes
if(MSVC10) if(MSVC10)
@ -974,12 +1031,14 @@ if ( MSVC )
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
endif ( MSVC ) endif ( MSVC )
if (UNZIP_FOUND) IF(NOT HUNTER_ENABLED)
if (UNZIP_FOUND)
SET (unzip_compile_SRCS "") SET (unzip_compile_SRCS "")
else (UNZIP_FOUND) else (UNZIP_FOUND)
SET (unzip_compile_SRCS ${unzip_SRCS}) SET (unzip_compile_SRCS ${unzip_SRCS})
INCLUDE_DIRECTORIES( "../contrib/unzip/" ) INCLUDE_DIRECTORIES( "../contrib/unzip/" )
endif (UNZIP_FOUND) endif (UNZIP_FOUND)
ENDIF(NOT HUNTER_ENABLED)
MESSAGE(STATUS "Enabled importer formats:${ASSIMP_IMPORTERS_ENABLED}") MESSAGE(STATUS "Enabled importer formats:${ASSIMP_IMPORTERS_ENABLED}")
MESSAGE(STATUS "Disabled importer formats:${ASSIMP_IMPORTERS_DISABLED}") MESSAGE(STATUS "Disabled importer formats:${ASSIMP_IMPORTERS_DISABLED}")
@ -1018,10 +1077,12 @@ SET( assimp_src
) )
ADD_DEFINITIONS( -DOPENDDLPARSER_BUILD ) ADD_DEFINITIONS( -DOPENDDLPARSER_BUILD )
INCLUDE_DIRECTORIES( IF(NOT HUNTER_ENABLED)
INCLUDE_DIRECTORIES(
${IRRXML_INCLUDE_DIR} ${IRRXML_INCLUDE_DIR}
../contrib/openddlparser/include ../contrib/openddlparser/include
) )
ENDIF(NOT HUNTER_ENABLED)
IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER) IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER)
SET( assimp_src ${assimp_src} ${C4D_SRCS}) SET( assimp_src ${assimp_src} ${C4D_SRCS})
@ -1037,7 +1098,22 @@ TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>
) )
TARGET_LINK_LIBRARIES(assimp ${ZLIB_LIBRARIES} ${OPENDDL_PARSER_LIBRARIES} ${IRRXML_LIBRARY} ) IF(HUNTER_ENABLED)
TARGET_LINK_LIBRARIES(assimp
PUBLIC
polyclipping::polyclipping
irrXML::irrXML
openddlparser::openddl_parser
poly2tri::poly2tri
minizip::minizip
ZLIB::zlib
RapidJSON::rapidjson
utf8::utf8
zip::zip
)
ELSE(HUNTER_ENABLED)
TARGET_LINK_LIBRARIES(assimp ${ZLIB_LIBRARIES} ${OPENDDL_PARSER_LIBRARIES} ${IRRXML_LIBRARY} )
ENDIF(HUNTER_ENABLED)
if(ASSIMP_ANDROID_JNIIOSYSTEM) if(ASSIMP_ANDROID_JNIIOSYSTEM)
set(ASSIMP_ANDROID_JNIIOSYSTEM_PATH port/AndroidJNI) set(ASSIMP_ANDROID_JNIIOSYSTEM_PATH port/AndroidJNI)
@ -1119,12 +1195,14 @@ ENDIF(APPLE)
# Build against external unzip, or add ../contrib/unzip so # Build against external unzip, or add ../contrib/unzip so
# assimp can #include "unzip.h" # assimp can #include "unzip.h"
if (UNZIP_FOUND) IF(NOT HUNTER_ENABLED)
if (UNZIP_FOUND)
INCLUDE_DIRECTORIES(${UNZIP_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${UNZIP_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES}) TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES})
else (UNZIP_FOUND) else (UNZIP_FOUND)
INCLUDE_DIRECTORIES("../") INCLUDE_DIRECTORIES("../")
endif (UNZIP_FOUND) endif (UNZIP_FOUND)
ENDIF(NOT HUNTER_ENABLED)
# Add RT-extension library for glTF importer with Open3DGC-compression. # Add RT-extension library for glTF importer with Open3DGC-compression.
IF (RT_FOUND AND ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC) IF (RT_FOUND AND ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC)

View File

@ -37,7 +37,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# #
#---------------------------------------------------------------------- #----------------------------------------------------------------------
cmake_minimum_required( VERSION 2.6 ) cmake_minimum_required( VERSION 3.0 )
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${Assimp_SOURCE_DIR}/contrib/gtest/include ${Assimp_SOURCE_DIR}/contrib/gtest/include