Use git submodule for assimp
This commit is contained in:
parent
f007f13d13
commit
dfffd14d5b
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "extern/assimp/assimp"]
|
||||||
|
path = extern/assimp/assimp
|
||||||
|
url = https://github.com/assimp/assimp.git
|
|
@ -19,16 +19,25 @@ set(CMAKE_AUTORCC ON)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
# Qtk build options
|
||||||
option(QTK_DEBUG "Enable debugger" ON)
|
option(QTK_DEBUG "Enable debugger" ON)
|
||||||
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
||||||
option(BUILD_ASSIMP "Add and build assimp as an external project" ON)
|
option(UPDATE_SUBMODULES "Update external project (assimp) git submodule" ON)
|
||||||
|
|
||||||
|
# Qt options
|
||||||
|
set(QT_DIR "$ENV{HOME}/Code/Clones/Qt/6.3.1/gcc_64/" CACHE PATH "Path to Qt6")
|
||||||
|
|
||||||
|
# Options for bringing your own assimp installation; Otherwise not needed
|
||||||
|
set(ASSIMP_DIR "" CACHE PATH "Path to local installation of assimp")
|
||||||
|
option(ASSIMP_NEW_INTERFACE "Use the assimp::assimp interface (WIN / OSX)" OFF)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# External Libraries
|
# External Libraries
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# For CLion builds, point CMAKE_PREFIX_PATH to Qt6 install directory
|
# For CLion builds, point CMAKE_PREFIX_PATH to Qt6 install directory
|
||||||
list(APPEND CMAKE_PREFIX_PATH $ENV{HOME}/Code/Clones/Qt/6.3.1/gcc_64/)
|
# + QtCreator will handle this for you if that is used instead
|
||||||
|
list(APPEND CMAKE_PREFIX_PATH "${QT_DIR}")
|
||||||
|
|
||||||
# Find Qt
|
# Find Qt
|
||||||
find_package(Qt6 COMPONENTS OpenGLWidgets)
|
find_package(Qt6 COMPONENTS OpenGLWidgets)
|
||||||
|
@ -37,41 +46,20 @@ if (NOT Qt6_FOUND)
|
||||||
message(FATAL_ERROR "Specify path to Qt6 with `cmake -DCMAKE_PREFIX_PATH=/path/to/Qt/6.x.x/gcc_64 -S /path/to/qtk -B /path/to/qtk/build && cmake --build /path/to/qtk/build -j $(nprocs)`")
|
message(FATAL_ERROR "Specify path to Qt6 with `cmake -DCMAKE_PREFIX_PATH=/path/to/Qt/6.x.x/gcc_64 -S /path/to/qtk -B /path/to/qtk/build && cmake --build /path/to/qtk/build -j $(nprocs)`")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# If no ASSIMP_DIR was provided via -DASSIMP_DIR=...
|
if (UPDATE_SUBMODULES)
|
||||||
# + Add assimp as external project
|
include("${CMAKE_SOURCE_DIR}/cmake/include/git_submodule.cmake")
|
||||||
# + If assimp is already available system-wide, we can just set -DBUILD_ASSIMP=OFF
|
submodule_update(extern/assimp/assimp/)
|
||||||
if (BUILD_ASSIMP AND NOT ASSIMP_DIR)
|
add_subdirectory(extern/assimp/assimp)
|
||||||
# Add Assimp as an external project
|
|
||||||
include(ExternalProject)
|
|
||||||
|
|
||||||
set(ASSIMP_PREFIX "${CMAKE_BINARY_DIR}/extern/assimp")
|
|
||||||
set(ASSIMP_INSTALL_DIR "${ASSIMP_PREFIX}/install")
|
|
||||||
set(ASSIMP_INCLUDE_DIR "${ASSIMP_INSTALL_DIR}/include")
|
|
||||||
set(ASSIMP_LIB_DIR "${ASSIMP_INSTALL_DIR}/lib")
|
|
||||||
set(ASSIMP_LIB "${CMAKE_SHARED_LIBRARY_PREFIX}assimp${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
|
||||||
file(MAKE_DIRECTORY "${ASSIMP_INCLUDE_DIR}")
|
|
||||||
|
|
||||||
ExternalProject_Add(
|
|
||||||
assimp-extern
|
|
||||||
PREFIX "${ASSIMP_PREFIX}"
|
|
||||||
INSTALL_DIR "${ASSIMP_INSTALL}"
|
|
||||||
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${ASSIMP_INSTALL_DIR}"
|
|
||||||
GIT_REPOSITORY https://github.com/assimp/assimp.git
|
|
||||||
GIT_PROGRESS ON
|
|
||||||
GIT_TAG v5.2.4
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(assimp STATIC IMPORTED)
|
|
||||||
set_target_properties(
|
|
||||||
assimp
|
|
||||||
PROPERTIES
|
|
||||||
IMPORTED_LOCATION "${ASSIMP_INSTALL_DIR}/lib/${ASSIMP_LIB}"
|
|
||||||
)
|
|
||||||
add_dependencies(assimp assimp-extern)
|
|
||||||
target_include_directories(assimp INTERFACE "${ASSIMP_INCLUDE_DIR}")
|
|
||||||
else()
|
else()
|
||||||
if (ASSIMP_DIR)
|
if (ASSIMP_DIR)
|
||||||
message(STATUS "ASSIMP_DIR: ${ASSIMP_DIR}")
|
message(STATUS "Using custom ASSIMP_DIR: ${ASSIMP_DIR}")
|
||||||
|
list(APPEND CMAKE_PREFIX_PATH "${ASSIMP_DIR}")
|
||||||
|
endif()
|
||||||
|
find_package(assimp REQUIRED)
|
||||||
|
if (assimp_FOUND)
|
||||||
|
message(STATUS "Found assimp: ${assimp_DIR}")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Could not find assimp at: ${CMAKE_PREFIX_PATH}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -121,7 +109,12 @@ set_target_properties(qtk-widget PROPERTIES
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(qtk-widget PUBLIC Qt6::OpenGLWidgets)
|
target_link_libraries(qtk-widget PUBLIC Qt6::OpenGLWidgets)
|
||||||
target_link_libraries(qtk-widget PRIVATE assimp)
|
|
||||||
|
if ((UPDATE_SUBMODULES AND NOT ASSIMP_DIR) OR NOT ASSIMP_NEW_INTERFACE)
|
||||||
|
target_link_libraries(qtk-widget PRIVATE assimp)
|
||||||
|
elseif(ASSIMP_NEW_INTERFACE)
|
||||||
|
target_link_libraries(qtk-widget PRIVATE assimp::assimp)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(QTK_DEBUG)
|
if(QTK_DEBUG)
|
||||||
target_compile_definitions(qtk-widget PUBLIC QTK_DEBUG)
|
target_compile_definitions(qtk-widget PUBLIC QTK_DEBUG)
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
################################################################################
|
||||||
|
## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ##
|
||||||
|
## ##
|
||||||
|
## CMake function to update git submodules ##
|
||||||
|
################################################################################
|
||||||
|
include_guard()
|
||||||
|
|
||||||
|
find_package(Git)
|
||||||
|
|
||||||
|
# _PATH: Path to git submodule location that we want to update
|
||||||
|
# + submodule_update(extern/assimp)
|
||||||
|
function(submodule_update _PATH)
|
||||||
|
if (NOT UPDATE_SUBMODULES)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT GIT_FOUND)
|
||||||
|
message(FATAL_ERROR "Error: No git executable found")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "${_PATH}")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} submodule update --init "${_PATH}"
|
||||||
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE result
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT result EQUAL 0)
|
||||||
|
message(FATAL_ERROR "Error: Unable to update git submodule at ${_PATH}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit bd64cc88dff17f118ecf32ebcbacaf566f6b6449
|
Loading…
Reference in New Issue