From 9336d0cb1a0abaaea5d62899daf351866392eed6 Mon Sep 17 00:00:00 2001 From: Dane Johnson Date: Fri, 5 Feb 2021 11:22:37 -0600 Subject: [PATCH] Externalize Assimp --- CMakeLists.txt | 2 +- cmake/modules/FindASSIMP.cmake | 33 +++++++++++++++++++++++++++++++++ core/CMakeLists.txt | 8 ++++++++ thirdparty/CMakeLists.txt | 7 ------- 4 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 cmake/modules/FindASSIMP.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 70a7750..924cb03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.13) project(Couch) -set(CMAKE_MODULE_PATH, ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR/cmake.}) +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) option(LUA_ENABLED "Lua scripting support" ON) if (LUA_ENABLED) diff --git a/cmake/modules/FindASSIMP.cmake b/cmake/modules/FindASSIMP.cmake new file mode 100644 index 0000000..ca8474a --- /dev/null +++ b/cmake/modules/FindASSIMP.cmake @@ -0,0 +1,33 @@ +# - Try to find Assimp +# Once done, this will define +# +# ASSIMP_FOUND - system has Assimp +# ASSIMP_INCLUDE_DIR - the Assimp include directories +# ASSIMP_LIBRARIES - link these to use Assimp +message(STATUS "Looking for Assimp") +FIND_PATH( ASSIMP_INCLUDE_DIR assimp/mesh.h + /usr/include + /usr/local/include + /opt/local/include + ${CMAKE_SOURCE_DIR}/includes + ) +FIND_LIBRARY( ASSIMP_LIBRARY assimp + /usr/lib64 + /usr/lib + /usr/local/lib + /opt/local/lib + ${CMAKE_SOURCE_DIR}/lib + ) +IF(ASSIMP_INCLUDE_DIR AND ASSIMP_LIBRARY) + SET( ASSIMP_FOUND TRUE ) + SET( ASSIMP_LIBRARIES ${ASSIMP_LIBRARY} ) +ENDIF(ASSIMP_INCLUDE_DIR AND ASSIMP_LIBRARY) +IF(ASSIMP_FOUND) + IF(NOT ASSIMP_FIND_QUIETLY) + MESSAGE(STATUS "Found ASSIMP: ${ASSIMP_LIBRARY}") + ENDIF(NOT ASSIMP_FIND_QUIETLY) +ELSE(ASSIMP_FOUND) + IF(ASSIMP_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find libASSIMP") + ENDIF(ASSIMP_FIND_REQUIRED) +ENDIF(ASSIMP_FOUND) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 7c92e62..d71e9ba 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -8,6 +8,9 @@ find_package(glfw3 3.3 REQUIRED) ## Find Bullet find_package(Bullet REQUIRED) +## Find AssImp +find_package(ASSIMP REQUIRED) + if (LUA_ENABLED) ## Find Lua find_package(Lua REQUIRED) @@ -71,6 +74,10 @@ target_include_directories(couchlib PUBLIC ${BULLET_INCLUDE_DIRS}) +target_include_directories(couchlib + PUBLIC + ${ASSIMP_INCLUDE_DIR}) + if(NOT WIN32) target_link_libraries(couchlib glfw) endif() @@ -80,6 +87,7 @@ if (LUA_ENABLED) target_link_libraries(couchlib ${LUA_LIBRARIES}) endif () target_link_libraries(couchlib ${BULLET_LIBRARIES}) +target_link_libraries(couchlib ${ASSIMP_LIBRARY}) ## Add documentation find_package(Doxygen REQUIRED diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 3576076..a3c7751 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -3,10 +3,3 @@ project(Couch) ## STB (image) target_include_directories(couchlib PUBLIC stb) - -## ASSIMP -set(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT FALSE CACHE BOOL "Turn off all assimp importers") -set(ASSIMP_BUILD_OBJ_IMPORTER ON CACHE BOOL "Turn on wavefront importer") -add_subdirectory(assimp) -target_link_libraries(couchlib assimp::assimp) -