Skip to content

Commit

Permalink
Add options to use system libraries for new dependencies [Author @roe…
Browse files Browse the repository at this point in the history
…hling] (isl-org#5893)

* Add option USE_SYSTEM_CURL
* Add option USE_SYSTEM_OPENSSL
* Add option USE_SYSTEM_VTK
* Treat OpenSSL as private dependency for cURL
* OpenSSL API compatibility
---------
Co-authored-by: Timo Röhling <[email protected]>
  • Loading branch information
ssheorey authored Feb 9, 2023
1 parent ef9b92c commit 1830785
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 42 deletions.
128 changes: 87 additions & 41 deletions 3rdparty/find_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -827,39 +827,60 @@ endif()
# - Curl should be linked before PNG, otherwise it will have undefined symbols.
# - openssl.cmake needs to be included before curl.cmake, for the
# BORINGSSL_ROOT_DIR variable.
include(${Open3D_3RDPARTY_DIR}/boringssl/boringssl.cmake)
include(${Open3D_3RDPARTY_DIR}/curl/curl.cmake)
open3d_import_3rdparty_library(3rdparty_curl
INCLUDE_DIRS ${CURL_INCLUDE_DIRS}
INCLUDE_ALL
LIB_DIR ${CURL_LIB_DIR}
LIBRARIES ${CURL_LIBRARIES}
DEPENDS ext_zlib ext_curl
)
if(APPLE)
# Missing frameworks: https://stackoverflow.com/a/56157695/1255535
# Link frameworks : https://stackoverflow.com/a/18330634/1255535
# Fixes error:
# ```
# Undefined symbols for architecture arm64:
# "_SCDynamicStoreCopyProxies", referenced from:
# _Curl_resolv in libcurl.a(hostip.c.o)
# ```
# The "Foundation" framework is already linked by GLFW.
target_link_libraries(3rdparty_curl INTERFACE "-framework SystemConfiguration")
if(USE_SYSTEM_CURL)
open3d_pkg_config_3rdparty_library(3rdparty_curl
SEARCH_ARGS libcurl
)
if(NOT 3rdparty_curl_FOUND)
set(USE_SYSTEM_CURL OFF)
endif()
endif()
list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_curl)
if(NOT USE_SYSTEM_CURL)
if(USE_SYSTEM_OPENSSL)
open3d_find_package_3rdparty_library(3rdparty_openssl
PACKAGE OpenSSL
TARGETS OpenSSL::Crypto
)
if(NOT 3rdparty_openssl_FOUND)
set(USE_SYSTEM_OPENSSL OFF)
endif()
endif()
if(NOT USE_SYSTEM_OPENSSL)
# BoringSSL
include(${Open3D_3RDPARTY_DIR}/boringssl/boringssl.cmake)
open3d_import_3rdparty_library(3rdparty_openssl
INCLUDE_DIRS ${BORINGSSL_INCLUDE_DIRS}
INCLUDE_ALL
INCLUDE_DIRS ${BORINGSSL_INCLUDE_DIRS}
LIB_DIR ${BORINGSSL_LIB_DIR}
LIBRARIES ${BORINGSSL_LIBRARIES}
DEPENDS ext_zlib ext_boringssl
)
endif()

# BoringSSL
open3d_import_3rdparty_library(3rdparty_openssl
INCLUDE_DIRS ${BORINGSSL_INCLUDE_DIRS}
INCLUDE_ALL
INCLUDE_DIRS ${BORINGSSL_INCLUDE_DIRS}
LIB_DIR ${BORINGSSL_LIB_DIR}
LIBRARIES ${BORINGSSL_LIBRARIES}
DEPENDS ext_zlib ext_boringssl
)
list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_openssl)
include(${Open3D_3RDPARTY_DIR}/curl/curl.cmake)
open3d_import_3rdparty_library(3rdparty_curl
INCLUDE_DIRS ${CURL_INCLUDE_DIRS}
INCLUDE_ALL
LIB_DIR ${CURL_LIB_DIR}
LIBRARIES ${CURL_LIBRARIES}
DEPENDS ext_zlib ext_curl
)
if(APPLE)
# Missing frameworks: https://stackoverflow.com/a/56157695/1255535
# Link frameworks : https://stackoverflow.com/a/18330634/1255535
# Fixes error:
# ```
# Undefined symbols for architecture arm64:
# "_SCDynamicStoreCopyProxies", referenced from:
# _Curl_resolv in libcurl.a(hostip.c.o)
# ```
# The "Foundation" framework is already linked by GLFW.
target_link_libraries(3rdparty_curl INTERFACE "-framework SystemConfiguration")
endif()
target_link_libraries(3rdparty_curl INTERFACE 3rdparty_openssl)
endif()
list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_curl)

# PNG
if(USE_SYSTEM_PNG)
Expand Down Expand Up @@ -1430,16 +1451,41 @@ else()
endif()

# VTK
include(${Open3D_3RDPARTY_DIR}/vtk/vtk_build.cmake)
open3d_import_3rdparty_library(3rdparty_vtk
HIDDEN
INCLUDE_DIRS ${VTK_INCLUDE_DIRS}
LIB_DIR ${VTK_LIB_DIR}
LIBRARIES ${VTK_LIBRARIES}
DEPENDS ext_vtk
)
if(UNIX AND NOT APPLE)
target_link_libraries(3rdparty_vtk INTERFACE ${CMAKE_DL_LIBS})
if(USE_SYSTEM_VTK)
open3d_find_package_3rdparty_library(3rdparty_vtk
PACKAGE VTK
TARGETS
VTK::FiltersGeneral
VTK::FiltersSources
VTK::FiltersModeling
VTK::FiltersCore
VTK::CommonExecutionModel
VTK::CommonDataModel
VTK::CommonTransforms
VTK::CommonMath
VTK::CommonMisc
VTK::CommonSystem
VTK::CommonCore
VTK::kissfft
VTK::pugixml
VTK::vtksys
)
if(NOT 3rdparty_vtk_FOUND)
set(USE_SYSTEM_VTK OFF)
endif()
endif()
if(NOT USE_SYSTEM_VTK)
include(${Open3D_3RDPARTY_DIR}/vtk/vtk_build.cmake)
open3d_import_3rdparty_library(3rdparty_vtk
HIDDEN
INCLUDE_DIRS ${VTK_INCLUDE_DIRS}
LIB_DIR ${VTK_LIB_DIR}
LIBRARIES ${VTK_LIBRARIES}
DEPENDS ext_vtk
)
if(UNIX AND NOT APPLE)
target_link_libraries(3rdparty_vtk INTERFACE ${CMAKE_DL_LIBS})
endif()
endif()
list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_vtk)

Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ else()
option(USE_SYSTEM_BLAS "Use system pre-installed openblas" ON )
endif()
option(USE_SYSTEM_ASSIMP "Use system pre-installed assimp" OFF)
option(USE_SYSTEM_CURL "Use system pre-installed curl" OFF)
option(USE_SYSTEM_EIGEN3 "Use system pre-installed eigen3" OFF)
option(USE_SYSTEM_FILAMENT "Use system pre-installed filament" OFF)
option(USE_SYSTEM_FMT "Use system pre-installed fmt" OFF)
Expand All @@ -102,12 +103,14 @@ option(USE_SYSTEM_JSONCPP "Use system pre-installed jsoncpp" OFF
option(USE_SYSTEM_LIBLZF "Use system pre-installed liblzf" OFF)
option(USE_SYSTEM_MSGPACK "Use system pre-installed msgpack" OFF)
option(USE_SYSTEM_NANOFLANN "Use system pre-installed nanoflann" OFF)
option(USE_SYSTEM_OPENSSL "Use system pre-installed OpenSSL" OFF)
option(USE_SYSTEM_PNG "Use system pre-installed png" OFF)
option(USE_SYSTEM_PYBIND11 "Use system pre-installed pybind11" OFF)
option(USE_SYSTEM_QHULLCPP "Use system pre-installed qhullcpp" OFF)
option(USE_SYSTEM_TBB "Use system pre-installed TBB" OFF)
option(USE_SYSTEM_TINYGLTF "Use system pre-installed tinygltf" OFF)
option(USE_SYSTEM_TINYOBJLOADER "Use system pre-installed tinyobjloader" OFF)
option(USE_SYSTEM_VTK "Use system pre-installed VTK" OFF)
option(USE_SYSTEM_ZEROMQ "Use system pre-installed ZeroMQ" OFF)
if(LINUX_AARCH64 OR APPLE_AARCH64)
option(BUILD_VTK_FROM_SOURCE "Build VTK from source" ON )
Expand Down
2 changes: 2 additions & 0 deletions cmake/Open3DPrintConfigurationSummary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function(open3d_print_configuration_summary)
set(3RDPARTY_DEPENDENCIES
Assimp
BLAS
curl
Eigen3
filament
fmt
Expand All @@ -95,6 +96,7 @@ function(open3d_print_configuration_summary)
tinyfiledialogs
TinyGLTF
tinyobjloader
VTK
WebRTC
ZeroMQ
)
Expand Down
4 changes: 3 additions & 1 deletion cpp/open3d/utility/Download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include "open3d/utility/Download.h"

// BoringSSL is currently compatible with OpenSSL 1.1.0
#define OPENSSL_API_COMPAT 10100
// clang-format off
// Must include openssl before curl to build on Windows.
#include <openssl/md5.h>
Expand All @@ -49,8 +51,8 @@
#include <iomanip>
#include <iostream>
#include <sstream>
#include <unordered_set>
#include <string>
#include <unordered_set>

#include "open3d/data/Dataset.h"
#include "open3d/utility/FileSystem.h"
Expand Down

0 comments on commit 1830785

Please sign in to comment.