Fix openvdb dependency in libslic3r

This commit is contained in:
tamasmeszaros 2019-10-25 15:48:01 +02:00
parent 5c0cd06f2f
commit 1cc7bd9976
4 changed files with 51 additions and 22 deletions

View File

@ -402,9 +402,6 @@ if(SLIC3R_STATIC)
set(USE_BLOSC TRUE) set(USE_BLOSC TRUE)
endif() endif()
#find_package(OpenVDB 5.0 COMPONENTS openvdb)
#slic3r_remap_configs(IlmBase::Half RelWithDebInfo Release)
# libslic3r, PrusaSlicer GUI and the PrusaSlicer executable. # libslic3r, PrusaSlicer GUI and the PrusaSlicer executable.
add_subdirectory(src) add_subdirectory(src)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT PrusaSlicer_app_console) set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT PrusaSlicer_app_console)

View File

@ -108,6 +108,18 @@ if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW) cmake_policy(SET CMP0074 NEW)
endif() endif()
if(OpenVDB_FIND_QUIETLY)
set (_quiet "QUIET")
else()
set (_quiet "")
endif()
if(OpenVDB_FIND_REQUIRED)
set (_required "REQUIRED")
else()
set (_required "")
endif()
# Include utility functions for version information # Include utility functions for version information
include(${CMAKE_CURRENT_LIST_DIR}/OpenVDBUtils.cmake) include(${CMAKE_CURRENT_LIST_DIR}/OpenVDBUtils.cmake)
@ -146,7 +158,7 @@ set(_OPENVDB_ROOT_SEARCH_DIR "")
# Additionally try and use pkconfig to find OpenVDB # Additionally try and use pkconfig to find OpenVDB
find_package(PkgConfig) find_package(PkgConfig ${_quiet} ${_required})
pkg_check_modules(PC_OpenVDB QUIET OpenVDB) pkg_check_modules(PC_OpenVDB QUIET OpenVDB)
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
@ -250,7 +262,7 @@ OPENVDB_ABI_VERSION_FROM_PRINT(
ABI OpenVDB_ABI ABI OpenVDB_ABI
) )
if(NOT OpenVDB_FIND_QUIET) if(NOT OpenVDB_FIND_QUIETLY)
if(NOT OpenVDB_ABI) if(NOT OpenVDB_ABI)
message(WARNING "Unable to determine OpenVDB ABI version from OpenVDB " message(WARNING "Unable to determine OpenVDB ABI version from OpenVDB "
"installation. The library major version \"${OpenVDB_MAJOR_VERSION}\" " "installation. The library major version \"${OpenVDB_MAJOR_VERSION}\" "
@ -268,7 +280,17 @@ endif()
# Add standard dependencies # Add standard dependencies
find_package(IlmBase COMPONENTS Half) macro(just_fail msg)
set(OpenVDB_FOUND FALSE)
if(OpenVDB_FIND_REQUIRED)
message(FATAL_ERROR msg)
elseif(NOT OpenVDB_FIND_QUIETLY)
message(ERROR msg)
endif()
return()
endmacro()
find_package(IlmBase QUIET COMPONENTS Half)
if(NOT IlmBase_FOUND) if(NOT IlmBase_FOUND)
pkg_check_modules(IlmBase QUIET IlmBase) pkg_check_modules(IlmBase QUIET IlmBase)
endif() endif()
@ -276,20 +298,20 @@ if (IlmBase_FOUND AND NOT TARGET IlmBase::Half)
message(STATUS "Falling back to IlmBase found by pkg-config...") message(STATUS "Falling back to IlmBase found by pkg-config...")
find_library(IlmHalf_LIBRARY NAMES Half) find_library(IlmHalf_LIBRARY NAMES Half)
if(IlmHalf_LIBRARY-NOTFOUND) if(IlmHalf_LIBRARY-NOTFOUND OR NOT IlmBase_INCLUDE_DIRS)
message(FATAL_ERROR "IlmBase::Half can not be found!") just_fail("IlmBase::Half can not be found!")
endif() endif()
add_library(IlmBase::Half UNKNOWN IMPORTED) add_library(IlmBase::Half UNKNOWN IMPORTED)
set_target_properties(IlmBase::Half PROPERTIES set_target_properties(IlmBase::Half PROPERTIES
IMPORTED_LOCATION "${IlmHalf_LIBRARY}" IMPORTED_LOCATION "${IlmHalf_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES ${IlmBase_INCLUDE_DIRS}) INTERFACE_INCLUDE_DIRECTORIES "${IlmBase_INCLUDE_DIRS}")
elseif(NOT IlmBase_FOUND) elseif(NOT IlmBase_FOUND)
message(FATAL_ERROR "IlmBase::Half can not be found!") just_fail("IlmBase::Half can not be found!")
endif() endif()
find_package(TBB REQUIRED COMPONENTS tbb) find_package(TBB ${_quiet} ${_required} COMPONENTS tbb)
find_package(ZLIB REQUIRED) find_package(ZLIB ${_quiet} ${_required})
find_package(Boost REQUIRED COMPONENTS iostreams system) find_package(Boost ${_quiet} ${_required} COMPONENTS iostreams system )
# Use GetPrerequisites to see which libraries this OpenVDB lib has linked to # Use GetPrerequisites to see which libraries this OpenVDB lib has linked to
# which we can query for optional deps. This basically runs ldd/otoll/objdump # which we can query for optional deps. This basically runs ldd/otoll/objdump
@ -350,7 +372,7 @@ unset(_OPENVDB_PREREQUISITE_LIST)
unset(_HAS_DEP) unset(_HAS_DEP)
if(OpenVDB_USES_BLOSC) if(OpenVDB_USES_BLOSC)
find_package(Blosc ) find_package(Blosc QUIET)
if(NOT Blosc_FOUND OR NOT TARGET Blosc::blosc) if(NOT Blosc_FOUND OR NOT TARGET Blosc::blosc)
message(STATUS "find_package could not find Blosc. Using fallback blosc search...") message(STATUS "find_package could not find Blosc. Using fallback blosc search...")
find_path(Blosc_INCLUDE_DIR blosc.h) find_path(Blosc_INCLUDE_DIR blosc.h)
@ -362,25 +384,25 @@ if(OpenVDB_USES_BLOSC)
IMPORTED_LOCATION "${Blosc_LIBRARY}" IMPORTED_LOCATION "${Blosc_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES ${Blosc_INCLUDE_DIR}) INTERFACE_INCLUDE_DIRECTORIES ${Blosc_INCLUDE_DIR})
elseif() elseif()
message(FATAL_ERROR "Blosc library can not be found!") just_fail("Blosc library can not be found!")
endif() endif()
endif() endif()
endif() endif()
if(OpenVDB_USES_LOG4CPLUS) if(OpenVDB_USES_LOG4CPLUS)
find_package(Log4cplus REQUIRED) find_package(Log4cplus ${_quiet} ${_required})
endif() endif()
if(OpenVDB_USES_ILM) if(OpenVDB_USES_ILM)
find_package(IlmBase REQUIRED) find_package(IlmBase ${_quiet} ${_required})
endif() endif()
if(OpenVDB_USES_EXR) if(OpenVDB_USES_EXR)
find_package(OpenEXR REQUIRED) find_package(OpenEXR ${_quiet} ${_required})
endif() endif()
if(UNIX) if(UNIX)
find_package(Threads REQUIRED) find_package(Threads ${_quiet} ${_required})
endif() endif()
# Set deps. Note that the order here is important. If we're building against # Set deps. Note that the order here is important. If we're building against
@ -481,7 +503,7 @@ foreach(COMPONENT ${OpenVDB_FIND_COMPONENTS})
endif() endif()
endforeach() endforeach()
if(OpenVDB_FOUND AND NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) if(OpenVDB_FOUND AND NOT OpenVDB_FIND_QUIETLY)
message(STATUS "OpenVDB libraries: ${OpenVDB_LIBRARIES}") message(STATUS "OpenVDB libraries: ${OpenVDB_LIBRARIES}")
endif() endif()

View File

@ -125,7 +125,9 @@ function(OPENVDB_ABI_VERSION_FROM_PRINT OPENVDB_PRINT)
cmake_parse_arguments(_VDB "QUIET" "ABI" "" ${ARGN}) cmake_parse_arguments(_VDB "QUIET" "ABI" "" ${ARGN})
if(NOT EXISTS ${OPENVDB_PRINT}) if(NOT EXISTS ${OPENVDB_PRINT})
message(WARNING "vdb_print not found! ${OPENVDB_PRINT}") if(NOT OpenVDB_FIND_QUIETLY)
message(WARNING "vdb_print not found! ${OPENVDB_PRINT}")
endif()
return() return()
endif() endif()
@ -148,7 +150,9 @@ function(OPENVDB_ABI_VERSION_FROM_PRINT OPENVDB_PRINT)
endif() endif()
if(${_VDB_PRINT_RETURN_STATUS}) if(${_VDB_PRINT_RETURN_STATUS})
message(WARNING "vdb_print returned with status ${_VDB_PRINT_RETURN_STATUS}") if(NOT OpenVDB_FIND_QUIETLY)
message(WARNING "vdb_print returned with status ${_VDB_PRINT_RETURN_STATUS}")
endif()
return() return()
endif() endif()

View File

@ -1,2 +1,8 @@
add_executable(openvdb_example openvdb_example.cpp) add_executable(openvdb_example openvdb_example.cpp)
find_package(OpenVDB 5.0 REQUIRED COMPONENTS openvdb)
slic3r_remap_configs(IlmBase::Half RelWithDebInfo Release)
target_link_libraries(openvdb_example libslic3r) target_link_libraries(openvdb_example libslic3r)
target_link_libraries(openvdb_example OpenVDB::openvdb)