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

build overlaybd using static compiled libcurl 7.42.1 #270

Merged
merged 1 commit into from
Sep 27, 2023
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
54 changes: 54 additions & 0 deletions CMake/FindCURL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
include(FetchContent)

if(${BUILD_CURL_FROM_SOURCE})
message("Add and build standalone libcurl")
include(FetchContent)
FetchContent_Declare(
curl_bundle
GIT_REPOSITORY https://github.com/curl/curl.git
GIT_TAG curl-7_42_1
GIT_PROGRESS 1)

FetchContent_GetProperties(curl_bundle)

# In libcurl, CMakeLists build static lib is broken add build command via
# make
if(NOT TARGET libcurl_static_build)
if (NOT curl_bundle_POPULATED)
FetchContent_Populate(curl_bundle)
endif()
add_custom_command(
OUTPUT ${curl_bundle_BINARY_DIR}/lib/libcurl.a
WORKING_DIRECTORY ${curl_bundle_SOURCE_DIR}
COMMAND
autoreconf -i && sh configure --with-openssl --without-libssh2
--enable-static --enable-shared=no --enable-optimize
--enable-symbol-hiding --disable-manual --without-libidn
--prefix=${curl_bundle_BINARY_DIR} && make -j && make install)
add_custom_target(libcurl_static_build
DEPENDS ${curl_bundle_BINARY_DIR}/lib/libcurl.a)
endif()

set(CURL_FOUND yes)
set(CURL_LIBRARY ${curl_bundle_BINARY_DIR}/lib/libcurl.a)
set(CURL_THIRDPARTY_DEPS crypto ssl z)
set(CURL_LIBRARIES ${CURL_LIBRARY} ${CURL_THIRDPARTY_DEPS})
set(CURL_INCLUDE_DIR ${curl_bundle_BINARY_DIR}/include)
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
set(CURL_VERSION_STRING 7.42.1)

# Use libcurl static lib instead of cmake defined shared lib
if(NOT TARGET CURL::libcurl)
add_library(CURL::libcurl UNKNOWN IMPORTED)
endif()
add_dependencies(CURL::libcurl libcurl_static_build)
message("${CURL_LIBRARY}")
set_target_properties(
CURL::libcurl
PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${CURL_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${CURL_THIRDPARTY_DEPS}")
else()
include(${CMAKE_ROOT}/Modules/FindCURL.cmake)
endif()
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED on)
set(ENABLE_MIMIC_VDSO off)

option(BUILD_CURL_FROM_SOURCE "Compile static libcurl" on)
find_package(photon REQUIRED)
find_package(tcmu REQUIRED)

Expand Down