Make assimp optional

This commit is contained in:
Georg Hagen
2024-05-22 14:38:51 +02:00
parent 640ca59dcd
commit cd2b8cc822
3 changed files with 42 additions and 21 deletions

View File

@@ -1,23 +1,39 @@
include(FetchContent)
if(NOT DEFINED ASSIMP_REPO)
set(ASSIMP_REPO https://github.com/assimp/assimp.git)
find_package(assimp QUIET)
if (assimp_FOUND)
message("Using system assimp")
elseif (USE_ASSIMP)
if(NOT DEFINED ASSIMP_REPO)
set(ASSIMP_REPO https://github.com/assimp/assimp.git)
endif ()
FetchContent_Declare(
assimp
EXCLUDE_FROM_ALL
GIT_REPOSITORY ${ASSIMP_REPO}
GIT_TAG v5.0.1
GIT_SHALLOW TRUE
)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
set(ASSIMP_INJECT_DEBUG_POSTFIX OFF CACHE BOOL "" FORCE)
set(ASSIMP_INSTALL OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(assimp)
set(assimp_FOUND ON PARENT_SCOPE)
endif ()
FetchContent_Declare(
assimp
EXCLUDE_FROM_ALL
GIT_REPOSITORY ${ASSIMP_REPO}
GIT_TAG v5.0.1
GIT_SHALLOW TRUE
)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
set(ASSIMP_INJECT_DEBUG_POSTFIX OFF CACHE BOOL "" FORCE)
set(ASSIMP_INSTALL OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(assimp)
function(LinkAssimp TARGET)
if (NOT assimp_FOUND)
find_package(assimp QUIET)
endif ()
if (assimp_FOUND)
target_link_libraries(${TARGET} PUBLIC assimp)
endif ()
endfunction()