|
| 1 | +cmake_minimum_required(VERSION 3.16) |
| 2 | +project(teaserpp VERSION 1.0.0) |
| 3 | + |
| 4 | +set(CMAKE_CXX_STANDARD 14) |
| 5 | + |
| 6 | +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/" ${CMAKE_MODULE_PATH}) |
| 7 | +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 8 | + |
| 9 | +# Check build types |
| 10 | +if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) |
| 11 | + message(STATUS "Setting build type to 'Release' as none was specified.") |
| 12 | + set(CMAKE_BUILD_TYPE "Release" CACHE |
| 13 | + STRING "Choose the type of build." FORCE) |
| 14 | +endif () |
| 15 | + |
| 16 | +if (DEFINED SKBUILD) |
| 17 | + message(STATUS "Building with Scikit-Build") |
| 18 | +endif () |
| 19 | + |
| 20 | +# Options |
| 21 | +option(BUILD_SHARED_LIBS "Build shared libraries" ON) |
| 22 | +option(BUILD_TESTS "Build tests" ON) |
| 23 | +option(BUILD_TEASER_FPFH "Build TEASER++ wrappers for PCL FPFH estimation." OFF) |
| 24 | +option(BUILD_MATLAB_BINDINGS "Build MATLAB bindings" OFF) |
| 25 | +option(BUILD_PYTHON_BINDINGS "Build Python bindings" OFF) |
| 26 | +option(BUILD_DOC "Build documentation" ON) |
| 27 | +option(BUILD_WITH_MARCH_NATIVE "Build with flag march=native" OFF) |
| 28 | +option(ENABLE_MKL "Try to use Eigen with MKL" OFF) |
| 29 | +option(ENABLE_DIAGNOSTIC_PRINT "Enable printing of diagnostic messages" ON) |
| 30 | + |
| 31 | +if (ENABLE_DIAGNOSTIC_PRINT) |
| 32 | + message(STATUS "Enable printing of diagnostic messages.") |
| 33 | + add_definitions(-DTEASER_DIAG_PRINT) |
| 34 | +endif () |
| 35 | + |
| 36 | +# Find dependencies |
| 37 | +# Eigen3 |
| 38 | +find_package(Eigen3 3.2 QUIET REQUIRED NO_MODULE) |
| 39 | +if (ENABLE_MKL) |
| 40 | + find_package(MKL) |
| 41 | + if (MKL_FOUND) |
| 42 | + message(STATUS "MKL found at: ${MKL_LIBRARIES}") |
| 43 | + include_directories(${MKL_INCLUDE_DIR}) |
| 44 | + add_definitions(-DEIGEN_USE_MKL_ALL) |
| 45 | + list(APPEND TEASERPP_BLAS_LAPACK_LIBS ${MKL_LIBRARIES}) |
| 46 | + else () |
| 47 | + message(STATUS "MKL not found.") |
| 48 | + endif () |
| 49 | +endif () |
| 50 | + |
| 51 | +if (BUILD_TEASER_FPFH) |
| 52 | + # Boost |
| 53 | + find_package(Boost 1.58 QUIET REQUIRED) |
| 54 | + |
| 55 | + # Suppress CMake warnings |
| 56 | + # see here: https://github.com/PointCloudLibrary/pcl/issues/3680 |
| 57 | + if(NOT DEFINED CMAKE_SUPPRESS_DEVELOPER_WARNINGS) |
| 58 | + set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE INTERNAL "No dev warnings") |
| 59 | + endif() |
| 60 | + find_package(PCL 1.8 QUIET REQUIRED COMPONENTS common io features kdtree) |
| 61 | + |
| 62 | + # check for -march=native in PCL compile definitions |
| 63 | + get_target_property(PCL_COMPILE_OPTIONS pcl_common INTERFACE_COMPILE_OPTIONS) |
| 64 | + string(FIND "${PCL_COMPILE_OPTIONS}" "-march=native" PCL_IS_NATIVE) |
| 65 | + if (NOT PCL_IS_NATIVE EQUAL -1) |
| 66 | + # Fix Eigen alignment conflicting with pcl issue |
| 67 | + # See: http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html |
| 68 | + add_definitions(-DEIGEN_MAX_STATIC_ALIGN_BYTES=0) |
| 69 | + |
| 70 | + if (NOT BUILD_WITH_MARCH_NATIVE) |
| 71 | + message (STATUS "PCL built with -march=native. Enable -march=native for TEASER++ as well") |
| 72 | + set(BUILD_WITH_MARCH_NATIVE ON) |
| 73 | + endif() |
| 74 | + endif() |
| 75 | +endif () |
| 76 | + |
| 77 | +# Building Targets |
| 78 | +set(TEASERPP_ROOT ${CMAKE_CURRENT_LIST_DIR}) |
| 79 | +add_subdirectory(teaser) |
| 80 | + |
| 81 | +if (BUILD_TESTS) |
| 82 | + enable_testing() |
| 83 | + add_subdirectory(test) |
| 84 | +endif () |
| 85 | + |
| 86 | +if (BUILD_DOC) |
| 87 | + add_subdirectory(doc EXCLUDE_FROM_ALL) |
| 88 | +endif () |
| 89 | + |
| 90 | +if (BUILD_MATLAB_BINDINGS) |
| 91 | + message(STATUS "Will build MATLAB bindings.") |
| 92 | + add_subdirectory(matlab) |
| 93 | +endif () |
| 94 | + |
| 95 | +if (BUILD_PYTHON_BINDINGS) |
| 96 | + message(STATUS "TEASER++ Python binding will be built.") |
| 97 | + add_subdirectory(python) |
| 98 | +endif () |
| 99 | + |
| 100 | +# export targets |
| 101 | +export(TARGETS ${TEASERPP_EXPORTED_TARGETS} FILE teaserpp-exports.cmake) |
| 102 | + |
| 103 | +install(FILES cmake/teaserppConfig.cmake |
| 104 | + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/teaserpp |
| 105 | + ) |
0 commit comments