Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update libcurl to version 7.75 and add SSL support #8463

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ matrix:
sudo: required
osx_image: xcode7
script:
- export OPENSSL_ROOT_DIR=`brew --prefix openssl` # Used by libcurl for 'CHECK_FOR_UPDATES' capability
- cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DCHECK_FOR_UPDATES=true
- cmake --build . --config $LRS_BUILD_CONFIG -- -j4
- ls
Expand All @@ -108,7 +109,7 @@ matrix:
dist: xenial
env: LRS_BUILD_ANDROID=true
script:
- cmake .. -DCMAKE_TOOLCHAIN_FILE=../android-ndk-r20b/build/cmake/android.toolchain.cmake -DCHECK_FOR_UPDATES=true
- cmake .. -DCMAKE_TOOLCHAIN_FILE=../android-ndk-r20b/build/cmake/android.toolchain.cmake
- cmake --build . --config $LRS_BUILD_CONFIG -- -j4
- ls

Expand Down
27 changes: 19 additions & 8 deletions CMake/external_libcurl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@ if(CHECK_FOR_UPDATES)
include(ExternalProject)
message(STATUS "Building libcurl enabled")

set(CURL_FLAGS -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DUSE_WIN32_LDAP=OFF -DHTTP_ONLY=ON -DCURL_ZLIB=OFF -DCURL_DISABLE_CRYPTO_AUTH=ON -DCMAKE_USE_OPENSSL=OFF -DCMAKE_USE_LIBSSH2=OFF -DBUILD_TESTING=OFF )
set(CURL_FLAGS -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DUSE_WIN32_LDAP=OFF -DHTTP_ONLY=ON -DCURL_ZLIB=OFF -DCURL_DISABLE_CRYPTO_AUTH=ON -DCMAKE_USE_LIBSSH2=OFF -DBUILD_TESTING=OFF )
if (WIN32)
set(CURL_FLAGS ${CURL_FLAGS} -DCURL_STATIC_CRT=ON )
endif()


# Add SSL library flag
if (WIN32)
set(CURL_FLAGS ${CURL_FLAGS} -DCMAKE_USE_SCHANNEL=ON )
else()
set(CURL_FLAGS ${CURL_FLAGS} -DCMAKE_USE_OPENSSL=ON )
endif()

ExternalProject_Add(
libcurl
PREFIX libcurl
GIT_REPOSITORY "https://github.com/curl/curl.git"
GIT_TAG "53cdc2c963e33bc0cc1a51ad2df79396202e07f8" # curl-7_70_0
GIT_TAG "2f33be817cbce6ad7a36f27dd7ada9219f13584c" # curl-7_75_0
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/libcurl
CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
Expand All @@ -37,13 +44,17 @@ if(CHECK_FOR_UPDATES)
add_definitions(-DCURL_STATICLIB) # Mandatory for building libcurl as static lib

target_include_directories(curl INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libcurl/libcurl_install/include>)

target_link_libraries(curl INTERFACE debug ${CMAKE_CURRENT_BINARY_DIR}/libcurl/libcurl_install/lib/${CURL_DEBUG_TARGET_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
Copy link
Collaborator

@ev-mp ev-mp Mar 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the keyword should be changed to PRIVATE as they are not supposed to be exposed in the DLL interface.
Same for the below entries

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was built same as libusb (the keyword is not part of this PR), ifI try to change it to private I get lots of cmake errors like:

CMake Error at CMake/external_libcurl.cmake:43 (add_library):
Cannot find source file:

PRIVATE

Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm

@maloel / @ev-mp , please say how much effort should be made for changing to PRIVATE.

According to CMAKE , INTERFACE is not like PUBLIC.

Libraries following INTERFACE are appended to the link interface and are not used for linking .

target_link_libraries(curl INTERFACE optimized ${CMAKE_CURRENT_BINARY_DIR}/libcurl/libcurl_install/lib/${CURL_RELEASE_TARGET_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})

# libcurl require ws2_32.lib for windows only
# libcurl required libs per OS
# (Linux require that the link dependency will be added after the libcurl link target that use it)
if (WIN32)
target_link_libraries(curl INTERFACE ws2_32.lib)
target_link_libraries(curl INTERFACE ws2_32.lib crypt32.lib)
else()
find_package(OpenSSL REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's required then it need to be propagated into the installation guide/scripts as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we can explain about the online update flag when it's doing nothing for now.
The default is false and the DB is empty

target_link_libraries(curl INTERFACE OpenSSL::SSL OpenSSL::Crypto)
endif()

target_link_libraries(curl INTERFACE debug ${CMAKE_CURRENT_BINARY_DIR}/libcurl/libcurl_install/lib/${CURL_DEBUG_TARGET_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
target_link_libraries(curl INTERFACE optimized ${CMAKE_CURRENT_BINARY_DIR}/libcurl/libcurl_install/lib/${CURL_RELEASE_TARGET_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})

endif() #CHECK_FOR_UPDATES
9 changes: 7 additions & 2 deletions CMake/global_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ macro(global_set_flags)
endif()

if(CHECK_FOR_UPDATES)
include(CMake/external_libcurl.cmake)
add_definitions(-DCHECK_FOR_UPDATES)
if (ANDROID_NDK_TOOLCHAIN_INCLUDED)
message(STATUS "Android build do not support CHECK_FOR_UPDATES flag, turning it off..")
set(CHECK_FOR_UPDATES false)
else()
include(CMake/external_libcurl.cmake)
add_definitions(-DCHECK_FOR_UPDATES)
endif()
endif()

add_definitions(-D${BACKEND} -DUNICODE)
Expand Down
2 changes: 1 addition & 1 deletion common/model-views.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ inline ImVec4 blend(const ImVec4& c, float a)

namespace rs2
{
constexpr const char* server_versions_db_url = "http://realsense-hw-public.s3-eu-west-1.amazonaws.com/Releases/rs_versions_db.json";
constexpr const char* server_versions_db_url = "https://librealsense.intel.com/Releases/rs_versions_db.json";

void prepare_config_file();

Expand Down
2 changes: 2 additions & 0 deletions common/sw-update/http-downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ namespace rs2
set_common_options(url);
curl_easy_setopt(_curl, CURLOPT_WRITEFUNCTION, stream_write_callback);
curl_easy_setopt(_curl, CURLOPT_WRITEDATA, &output);
curl_easy_setopt(_curl, CURLOPT_SSL_VERIFYPEER ,0L);
curl_easy_setopt(_curl, CURLOPT_SSL_VERIFYHOST ,0L);

progress_data progress_record; // Should stay here - "curl_easy_perform" use it
if (user_callback_func)
Expand Down