Commit f3b0d0ab authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

[CMake] use a custom module for assimp

Because using its .pc would not work on Windows, and its -config.cmake
is broken.

While here remove switch for assimp < 2.0, as assimp v3 is from 2014.
parent f24bc92a
...@@ -61,6 +61,10 @@ include(cmake/hpp.cmake) ...@@ -61,6 +61,10 @@ include(cmake/hpp.cmake)
include(cmake/apple.cmake) include(cmake/apple.cmake)
include(cmake/ide.cmake) include(cmake/ide.cmake)
SET(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake-modules/
${CMAKE_MODULE_PATH})
# If needed, fix CMake policy for APPLE systems # If needed, fix CMake policy for APPLE systems
APPLY_DEFAULT_APPLE_CONFIGURATION() APPLY_DEFAULT_APPLE_CONFIGURATION()
...@@ -116,7 +120,7 @@ if(HPP_FCL_HAS_QHULL) ...@@ -116,7 +120,7 @@ if(HPP_FCL_HAS_QHULL)
) )
endif() endif()
ADD_PROJECT_DEPENDENCY(assimp REQUIRED PKG_CONFIG_REQUIRES "assimp >= 2.0.0") FIND_PACKAGE(assimp REQUIRED)
SET(${PROJECT_NAME}_HEADERS SET(${PROJECT_NAME}_HEADERS
include/hpp/fcl/collision_data.h include/hpp/fcl/collision_data.h
......
#
# Copyright 2020 CNRS
#
# Author: Guilhem Saurel
#
# Try to find assimp in standard prefixes and in ${assimp_PREFIX}
# Once done this will define
# assimp_FOUND - System has assimp
# assimp_INCLUDE_DIR - The assimp include directories
# assimp_LIBRARY - The libraries needed to use assimp
FIND_PATH(assimp_INCLUDE_DIR
NAMES assimp/defs.h
PATHS ${assimp_PREFIX} ${assimp_PREFIX}/include
)
FIND_LIBRARY(assimp_LIBRARY
NAMES libassimp.so
PATHS ${assimp_PREFIX} ${assimp_PREFIX}/lib
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(assimp DEFAULT_MSG assimp_LIBRARY assimp_INCLUDE_DIR)
mark_as_advanced(assimp_INCLUDE_DIR assimp_LIBRARY)
...@@ -156,21 +156,22 @@ add_library(${LIBRARY_NAME} ...@@ -156,21 +156,22 @@ add_library(${LIBRARY_NAME}
ADD_SOURCE_GROUP(${LIBRARY_NAME}_SOURCES) ADD_SOURCE_GROUP(${LIBRARY_NAME}_SOURCES)
ADD_HEADER_GROUP(PROJECT_HEADERS_FULL_PATH) ADD_HEADER_GROUP(PROJECT_HEADERS_FULL_PATH)
FIND_LIBRARY(ASSIMP_FULL_LIB NAMES assimp PATHS ${ASSIMP_LIBRARY_DIRS} NO_DEFAULT_PATH)
MESSAGE(STATUS "assimp: ${ASSIMP_FULL_LIB}")
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
PUBLIC PUBLIC
${Boost_THREAD_LIBRARY} ${Boost_THREAD_LIBRARY}
${Boost_DATE_TIME_LIBRARY} ${Boost_DATE_TIME_LIBRARY}
${Boost_SYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}
${ASSIMP_FULL_LIB}
# assimp::assimp # Not working
# Boost::thread # Boost::thread
# Boost::date_time # Boost::date_time
# Boost::system # Boost::system
) )
TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
PRIVATE
${assimp_LIBRARY}
# assimp::assimp # Not working
)
if(HPP_FCL_HAS_QHULL) if(HPP_FCL_HAS_QHULL)
target_compile_definitions(${LIBRARY_NAME} PRIVATE -DHPP_FCL_HAS_QHULL) target_compile_definitions(${LIBRARY_NAME} PRIVATE -DHPP_FCL_HAS_QHULL)
target_include_directories(${LIBRARY_NAME} SYSTEM PRIVATE target_include_directories(${LIBRARY_NAME} SYSTEM PRIVATE
...@@ -182,7 +183,7 @@ target_include_directories(${LIBRARY_NAME} ...@@ -182,7 +183,7 @@ target_include_directories(${LIBRARY_NAME}
SYSTEM PUBLIC SYSTEM PUBLIC
${EIGEN3_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR}
${Boost_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
${ASSIMP_INCLUDE_DIRS} ${assimp_INCLUDE_DIR}
) )
target_include_directories(${LIBRARY_NAME} target_include_directories(${LIBRARY_NAME}
...@@ -190,12 +191,6 @@ target_include_directories(${LIBRARY_NAME} ...@@ -190,12 +191,6 @@ target_include_directories(${LIBRARY_NAME}
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
) )
if (NOT ${ASSIMP_VERSION} VERSION_LESS "2.0.1150")
target_compile_definitions(${LIBRARY_NAME} PRIVATE -DHPP_FCL_USE_ASSIMP_UNIFIED_HEADER_NAMES)
message(STATUS "Assimp version has unified headers")
else()
message(STATUS "Assimp version does not have unified headers")
endif()
IF(octomap_FOUND) IF(octomap_FOUND)
target_include_directories(${LIBRARY_NAME} SYSTEM PUBLIC ${OCTOMAP_INCLUDE_DIRS}) target_include_directories(${LIBRARY_NAME} SYSTEM PUBLIC ${OCTOMAP_INCLUDE_DIRS})
target_link_libraries(${LIBRARY_NAME} PUBLIC ${OCTOMAP_LIBRARIES}) target_link_libraries(${LIBRARY_NAME} PUBLIC ${OCTOMAP_LIBRARIES})
......
...@@ -45,21 +45,12 @@ ...@@ -45,21 +45,12 @@
#define AI_NO_EXCEPT #define AI_NO_EXCEPT
#endif #endif
#ifdef HPP_FCL_USE_ASSIMP_UNIFIED_HEADER_NAMES #include <assimp/DefaultLogger.hpp>
#include <assimp/DefaultLogger.hpp> #include <assimp/IOStream.hpp>
#include <assimp/IOStream.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/IOSystem.hpp> #include <assimp/Importer.hpp>
#include <assimp/Importer.hpp> #include <assimp/postprocess.h>
#include <assimp/postprocess.h> #include <assimp/scene.h>
#include <assimp/scene.h>
#else
#include <assimp/DefaultLogger.h>
#include <assimp/assimp.hpp>
#include <assimp/IOStream.h>
#include <assimp/IOSystem.h>
#include <assimp/aiPostProcess.h>
#include <assimp/aiScene.h>
#endif
namespace hpp namespace hpp
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment