Skip to content

Commit

Permalink
Support USE_SYSTEM_LIBREALSENSE flag. (#3057)
Browse files Browse the repository at this point in the history
  • Loading branch information
NobuoTsukamoto committed Feb 20, 2021
1 parent c006b94 commit 41fcfdc
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions 3rdparty/find_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -540,20 +540,42 @@ list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS "${TRITRIINTERSECT_TARGET}")

# librealsense SDK
if (BUILD_LIBREALSENSE)
include(${Open3D_3RDPARTY_DIR}/librealsense/librealsense.cmake)
import_3rdparty_library(3rdparty_librealsense
INCLUDE_DIRS ${LIBREALSENSE_INCLUDE_DIR}
LIBRARIES ${LIBREALSENSE_LIBRARIES}
LIB_DIR ${LIBREALSENSE_LIB_DIR}
)
add_dependencies(3rdparty_librealsense ext_librealsense)
set(LIBREALSENSE_TARGET "3rdparty_librealsense")
list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS "${LIBREALSENSE_TARGET}")

if (UNIX AND NOT APPLE) # Ubuntu dependency: libudev-dev
find_library(UDEV_LIBRARY udev REQUIRED
DOC "Library provided by the deb package libudev-dev")
target_link_libraries(3rdparty_librealsense INTERFACE ${UDEV_LIBRARY})
if(USE_SYSTEM_LIBREALSENSE AND NOT GLIBCXX_USE_CXX11_ABI)
# Turn off USE_SYSTEM_LIBREALSENSE.
# Because it is affected by libraries built with different CXX ABIs.
# See details: https://github.com/intel-isl/Open3D/pull/2876
message(STATUS "Set USE_SYSTEM_LIBREALSENSE=OFF, because GLIBCXX_USE_CXX11_ABI is OFF.")
set(USE_SYSTEM_LIBREALSENSE OFF)
endif()
if(USE_SYSTEM_LIBREALSENSE)
find_package(realsense2)
if(TARGET realsense2::realsense2)
message(STATUS "Using installed third-party library librealsense")
if(NOT BUILD_SHARED_LIBS)
list(APPEND Open3D_3RDPARTY_EXTERNAL_MODULES "realsense2")
endif()
set(LIBREALSENSE_TARGET "realsense2::realsense2")
list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS "${LIBREALSENSE_TARGET}")
else()
message(STATUS "Unable to find installed third-party library librealsense")
set(USE_SYSTEM_LIBREALSENSE OFF)
endif()
endif()
if(NOT USE_SYSTEM_LIBREALSENSE)
include(${Open3D_3RDPARTY_DIR}/librealsense/librealsense.cmake)
import_3rdparty_library(3rdparty_librealsense
INCLUDE_DIRS ${LIBREALSENSE_INCLUDE_DIR}
LIBRARIES ${LIBREALSENSE_LIBRARIES}
LIB_DIR ${LIBREALSENSE_LIB_DIR}
)
add_dependencies(3rdparty_librealsense ext_librealsense)
set(LIBREALSENSE_TARGET "3rdparty_librealsense")
list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS "${LIBREALSENSE_TARGET}")
if (UNIX AND NOT APPLE) # Ubuntu dependency: libudev-dev
find_library(UDEV_LIBRARY udev REQUIRED
DOC "Library provided by the deb package libudev-dev")
target_link_libraries(3rdparty_librealsense INTERFACE ${UDEV_LIBRARY})
endif()
endif()
endif()

Expand Down

0 comments on commit 41fcfdc

Please sign in to comment.