CMake: Detect and build support for Assimp

This commit is contained in:
Sam Edwards 2018-11-12 15:49:08 -07:00
parent 226dc69af2
commit 1ae736f881
4 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,28 @@
# Filename: FindAssimp.cmake
# Authors: CFSworks (9 Nov, 2018)
#
# Usage:
# find_package(Assimp [REQUIRED] [QUIET])
#
# Once done this will define:
# ASSIMP_FOUND - system has Assimp
# ASSIMP_INCLUDE_DIR - the path to the location of the assimp/ directory
# ASSIMP_LIBRARY - the library to link against for Assimp
#
if(NOT ASSIMP_INCLUDE_DIR)
find_path(ASSIMP_INCLUDE_DIR
NAMES "assimp/Importer.hpp")
mark_as_advanced(ASSIMP_INCLUDE_DIR)
endif()
if(NOT ASSIMP_LIBRARY)
find_library(ASSIMP_LIBRARY
NAMES "assimp")
mark_as_advanced(ASSIMP_LIBRARY)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Assimp DEFAULT_MSG ASSIMP_INCLUDE_DIR ASSIMP_LIBRARY)

View File

@ -161,6 +161,17 @@ package_option(TAR
package_status(TAR "libtar")
#
# ------------ Asset formats ------------
#
# Assimp
find_package(Assimp QUIET)
package_option(ASSIMP
"Build pandatool with support for loading 3D assets supported by Assimp.")
package_status(ASSIMP "Assimp")
#
# ------------ Math libraries ------------
#

View File

@ -3,6 +3,7 @@ if(NOT BUILD_PANDA)
endif()
# Include pandatool source directories
add_subdirectory(src/assimp)
add_subdirectory(src/bam)
add_subdirectory(src/converter)
add_subdirectory(src/cvscopy)

View File

@ -0,0 +1,29 @@
if(NOT HAVE_ASSIMP)
return()
endif()
set(P3ASSIMP_HEADERS
assimpLoader.h assimpLoader.I
config_assimp.h
loaderFileTypeAssimp.h
pandaIOStream.h
pandaIOSystem.h
pandaLogger.h
)
set(P3ASSIMP_SOURCES
assimpLoader.cxx
config_assimp.cxx
loaderFileTypeAssimp.cxx
pandaIOStream.cxx
pandaIOSystem.cxx
pandaLogger.cxx
)
composite_sources(p3assimp P3ASSIMP_SOURCES)
add_library(p3assimp ${MODULE_TYPE} ${P3ASSIMP_HEADERS} ${P3ASSIMP_SOURCES})
set_target_properties(p3assimp PROPERTIES DEFINE_SYMBOL BUILDING_ASSIMP)
target_link_libraries(p3assimp p3pandatoolbase
PKG::ASSIMP)
install(TARGETS p3assimp DESTINATION ${MODULE_DESTINATION})