Skip to content

Commit

Permalink
build overlaybd using static compiled libcurl 7.42.1
Browse files Browse the repository at this point in the history
Signed-off-by: 鸣舟 <[email protected]>
  • Loading branch information
Coldwings committed Sep 26, 2023
1 parent ceb8a3f commit 869d632
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
sudo apt-get update -y
sudo apt-get install -y libgflags-dev libcurl4-openssl-dev libssl-dev libaio-dev libnl-3-dev libnl-genl-3-dev libzstd-dev
sudo apt-get install -y uuid-dev libjson-c-dev libkmod-dev libsystemd-dev autoconf automake libtool libpci-dev nasm
sudo apt-get install -y libext2fs-dev
sudo apt-get install -y libext2fs-dev help2man
wget https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz
tar -zxvf release-1.11.0.tar.gz
cd googletest-release-1.11.0/
Expand Down
78 changes: 78 additions & 0 deletions CMake/FindCURL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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)
if(NOT curl_bundle_POPULATED)
FetchContent_Populate(curl_bundle)

if(NOT EXISTS ${curl_bundle_BINARY_DIR}/lib/libcurl.a
OR NOT EXISTS ${curl_bundle_BINARY_DIR}/include/curl/curl.h)
execute_process(
COMMAND autoreconf -i
WORKING_DIRECTORY ${curl_bundle_SOURCE_DIR}
COMMAND_ECHO STDOUT)

execute_process(
COMMAND
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}
WORKING_DIRECTORY ${curl_bundle_SOURCE_DIR}
COMMAND_ECHO STDOUT)

execute_process(
COMMAND make -j
WORKING_DIRECTORY ${curl_bundle_SOURCE_DIR}
COMMAND_ECHO STDOUT)

execute_process(
COMMAND make install
WORKING_DIRECTORY ${curl_bundle_SOURCE_DIR}
COMMAND_ECHO STDOUT)
endif()

endif()

include_directories(${curl_bundle_BINARY_DIR}/include)
link_directories(${curl_bundle_BINARY_DIR}/lib)
message("${curl_bundle_BINARY_DIR}")

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

if(NOT TARGET CURL::libcurl)
add_library(CURL::libcurl UNKNOWN IMPORTED)
set_target_properties(CURL::libcurl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}")

if(EXISTS "${CURL_LIBRARY}")
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${CURL_LIBRARY}")
endif()
if(CURL_LIBRARY_RELEASE)
set_property(TARGET CURL::libcurl APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}")
endif()
target_link_libraries(CURL::libcurl INTERFACE crypto ssl)
endif()
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

0 comments on commit 869d632

Please sign in to comment.