static_zlib
kimkulling 2021-01-20 10:42:46 +01:00
parent 109ded407d
commit 4b14b702ae
2 changed files with 77 additions and 29 deletions

View File

@ -446,46 +446,46 @@ ENDIF()
# 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(ASSIMP_HUNTER_ENABLED) #IF(ASSIMP_HUNTER_ENABLED)
hunter_add_package(ZLIB) # hunter_add_package(ZLIB)
find_package(ZLIB CONFIG REQUIRED) # find_package(ZLIB CONFIG REQUIRED)#
add_definitions(-DASSIMP_BUILD_NO_OWN_ZLIB) # add_definitions(-DASSIMP_BUILD_NO_OWN_ZLIB)
set(ZLIB_FOUND TRUE) # set(ZLIB_FOUND TRUE)
set(ZLIB_LIBRARIES ZLIB::zlib) # set(ZLIB_LIBRARIES ZLIB::zlib)
set(ASSIMP_BUILD_MINIZIP TRUE) # set(ASSIMP_BUILD_MINIZIP TRUE)
ELSE() #ELSE()
IF ( NOT ASSIMP_BUILD_ZLIB ) # IF ( NOT ASSIMP_BUILD_ZLIB )
FIND_PACKAGE(ZLIB) # FIND_PACKAGE(ZLIB)
ENDIF() # ENDIF()
IF( NOT ZLIB_FOUND ) # IF( NOT ZLIB_FOUND )
MESSAGE(STATUS "compiling zlib from sources") # MESSAGE(STATUS "compiling zlib from sources")
INCLUDE(CheckIncludeFile) # INCLUDE(CheckIncludeFile)
INCLUDE(CheckTypeSize) # INCLUDE(CheckTypeSize)
INCLUDE(CheckFunctionExists) # INCLUDE(CheckFunctionExists)
# Explicitly turn off ASM686 and AMD64 cmake options. # Explicitly turn off ASM686 and AMD64 cmake options.
# The AMD64 option causes a build failure on MSVC and the ASM builds seem to have problems: # The AMD64 option causes a build failure on MSVC and the ASM builds seem to have problems:
# https://github.com/madler/zlib/issues/41#issuecomment-125848075 # https://github.com/madler/zlib/issues/41#issuecomment-125848075
# Also prevents these options from "polluting" the cmake options if assimp is being # Also prevents these options from "polluting" the cmake options if assimp is being
# included as a submodule. # included as a submodule.
set( ASM686 FALSE CACHE INTERNAL "Override ZLIB flag to turn off assembly" FORCE ) # set( ASM686 FALSE CACHE INTERNAL "Override ZLIB flag to turn off assembly" FORCE )
set( AMD64 FALSE CACHE INTERNAL "Override ZLIB flag to turn off assembly" FORCE ) # set( AMD64 FALSE CACHE INTERNAL "Override ZLIB flag to turn off assembly" FORCE )
# compile from sources # compile from sources
ADD_SUBDIRECTORY(contrib/zlib) # ADD_SUBDIRECTORY(contrib/zlib)
SET(ZLIB_FOUND 1) # SET(ZLIB_FOUND 1)
SET(ZLIB_LIBRARIES zlibstatic) # SET(ZLIB_LIBRARIES zlibstatic)
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() #ELSE()
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() # ENDIF()
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) # INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
ENDIF() #ENDIF()
IF( NOT IOS ) IF( NOT IOS )
IF( NOT ASSIMP_BUILD_MINIZIP ) IF( NOT ASSIMP_BUILD_MINIZIP )

View File

@ -951,6 +951,53 @@ ELSE()
SOURCE_GROUP( ziplib FILES ${ziplib_SRCS} ) SOURCE_GROUP( ziplib FILES ${ziplib_SRCS} )
ENDIF() ENDIF()
IF(ASSIMP_HUNTER_ENABLED)
hunter_add_package(ZLIB)
find_package(ZLIB CONFIG REQUIRED)
add_definitions(-DASSIMP_BUILD_NO_OWN_ZLIB)
set(ZLIB_FOUND TRUE)
set(ZLIB_LIBRARIES ZLIB::zlib)
set(ASSIMP_BUILD_MINIZIP TRUE)
SET(ZLIB_LIBRARIES_LINKED -lz)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
ELSE()
IF ( NOT ASSIMP_BUILD_ZLIB )
FIND_PACKAGE(ZLIB)
ELSE()
SET( zlib_SRCS
../contrib/zlib/crc32.h
../contrib/zlib/deflate.h
../contrib/zlib/gzguts.h
../contrib/zlib/inffast.h
../contrib/zlib/inffixed.h
../contrib/zlib/inflate.h
../contrib/zlib/inftrees.h
../contrib/zlib/trees.h
../contrib/zlib/zutil.h
../contrib/zlib/adler32.c
../contrib/zlib/compress.c
../contrib/zlib/crc32.c
../contrib/zlib/deflate.c
../contrib/zlib/gzclose.c
../contrib/zlib/gzlib.c
../contrib/zlib/gzread.c
../contrib/zlib/gzwrite.c
../contrib/zlib/inflate.c
../contrib/zlib/infback.c
../contrib/zlib/inftrees.c
../contrib/zlib/inffast.c
../contrib/zlib/trees.c
../contrib/zlib/uncompr.c
../contrib/zlib/zutil.c
)
INCLUDE_DIRECTORIES(../contrib/zlib/)
set( ASM686 FALSE CACHE INTERNAL "Override ZLIB flag to turn off assembly" FORCE )
set( AMD64 FALSE CACHE INTERNAL "Override ZLIB flag to turn off assembly" FORCE )
SOURCE_GROUP( zlib FILES ${zlib_SRCS} )
ENDIF()
ENDIF()
# openddlparser # openddlparser
IF(ASSIMP_HUNTER_ENABLED) IF(ASSIMP_HUNTER_ENABLED)
hunter_add_package(openddlparser) hunter_add_package(openddlparser)
@ -1098,6 +1145,7 @@ SET( assimp_src
${open3dgc_SRCS} ${open3dgc_SRCS}
${ziplib_SRCS} ${ziplib_SRCS}
${Pugixml_SRCS} ${Pugixml_SRCS}
${zlib_SRCS}
# Necessary to show the headers in the project when using the VC++ generator: # Necessary to show the headers in the project when using the VC++ generator:
${PUBLIC_HEADERS} ${PUBLIC_HEADERS}