Skip to content

Commit

Permalink
libgui|Assimp|CMake: Added option to not use customized Assimp
Browse files Browse the repository at this point in the history
Instead, find Assimp with pkg-config.
  • Loading branch information
skyjake committed Jun 25, 2017
1 parent 8ea5f63 commit c9c4b5f
Showing 1 changed file with 40 additions and 36 deletions.
76 changes: 40 additions & 36 deletions doomsday/sdk/libgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,56 @@
cmake_minimum_required (VERSION 3.1)
project (DENG_LIBGUI)

option (DENG_ASSIMP_EMBEDDED "Use the Assimp from 'external/assimp' instead of system libraries" YES)

set (CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)

#----------------------------------------------------------------------------------------
# Configure Assimp first as a static library. Doomsday's Config is not
# included yet so that Assimp's build products are not included in
# the client component.
set (ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "Assimp: Build tools" FORCE)
set (ASSIMP_BUILD_TESTS OFF CACHE BOOL "Assimp: Build tests" FORCE)
set (BUILD_SHARED_LIBS OFF CACHE BOOL "Assimp: Shared library" FORCE)
if (APPLE OR WIN32)
set (ASSIMP_LIB_INSTALL_DIR ${DENG_INSTALL_LIB_DIR}
CACHE PATH "libassimp install directory" FORCE
)
else ()
set (ASSIMP_LIB_INSTALL_DIR ${DENG_INSTALL_PLUGIN_DIR}
CACHE PATH "libassimp install directory" FORCE
)
endif ()

# Enable only the relevant Assimp model importers.
set (_allAssimpFormats
3DS AC ASE ASSBIN ASSXML B3D BVH COLLADA DXF CSM HMP IRR LWO LWS MD2 MD3 MD5
MDC MDL NFF NDO OFF OBJ OGRE OPENGEX PLY MS3D COB BLEND IFC XGL FBX Q3D Q3BSP RAW SMD
STL TERRAGEN 3D X)
set (_enabledAssimpFormats 3DS COLLADA MD2 MD3 MD5 MDL OBJ BLEND FBX IRR)
foreach (_fmt ${_allAssimpFormats})
list (FIND _enabledAssimpFormats ${_fmt} _pos)
if (_pos GREATER -1)
set (_enabled YES)
if (DENG_ASSIMP_EMBEDDED)
set (ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "Assimp: Build tools" FORCE)
set (ASSIMP_BUILD_TESTS OFF CACHE BOOL "Assimp: Build tests" FORCE)
set (BUILD_SHARED_LIBS OFF CACHE BOOL "Assimp: Shared library" FORCE)
if (APPLE OR WIN32)
set (ASSIMP_LIB_INSTALL_DIR ${DENG_INSTALL_LIB_DIR}
CACHE PATH "libassimp install directory" FORCE
)
else ()
set (_enabled NO)
set (ASSIMP_LIB_INSTALL_DIR ${DENG_INSTALL_PLUGIN_DIR}
CACHE PATH "libassimp install directory" FORCE
)
endif ()
set (ASSIMP_BUILD_${_fmt}_IMPORTER ${_enabled} CACHE BOOL "Assimp: Enable ${_fmt} importer")
endforeach (_fmt)

set (CMAKE_AUTOMOC OFF)
set (oldCFlags ${CMAKE_C_FLAGS})
if (NOT MSVC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-incompatible-pointer-types")
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-address-of-packed-member")
# Enable only the relevant Assimp model importers.
set (_allAssimpFormats
3DS AC ASE ASSBIN ASSXML B3D BVH COLLADA DXF CSM HMP IRR LWO LWS MD2 MD3 MD5
MDC MDL NFF NDO OFF OBJ OGRE OPENGEX PLY MS3D COB BLEND IFC XGL FBX Q3D Q3BSP RAW SMD
STL TERRAGEN 3D X)
set (_enabledAssimpFormats 3DS COLLADA MD2 MD3 MD5 MDL OBJ BLEND FBX IRR)
foreach (_fmt ${_allAssimpFormats})
list (FIND _enabledAssimpFormats ${_fmt} _pos)
if (_pos GREATER -1)
set (_enabled YES)
else ()
set (_enabled NO)
endif ()
set (ASSIMP_BUILD_${_fmt}_IMPORTER ${_enabled} CACHE BOOL "Assimp: Enable ${_fmt} importer")
endforeach (_fmt)

set (CMAKE_AUTOMOC OFF)
set (oldCFlags ${CMAKE_C_FLAGS})
if (NOT MSVC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-incompatible-pointer-types")
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-address-of-packed-member")
endif ()
add_subdirectory (../../external/assimp assimp)
set_property (TARGET assimp PROPERTY FOLDER Libraries)
set (CMAKE_C_FLAGS ${oldCFlags})
endif ()
add_subdirectory (../../external/assimp assimp)
set_property (TARGET assimp PROPERTY FOLDER Libraries)
set (CMAKE_C_FLAGS ${oldCFlags})
#----------------------------------------------------------------------------------------

# Apply Doomsday's configuration.
Expand Down

0 comments on commit c9c4b5f

Please sign in to comment.