-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yifan Yuan <tuji.yyf@alibaba-inc.com>
- Loading branch information
Showing
70 changed files
with
3,505 additions
and
2,171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
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() | ||
find_package(openssl) | ||
add_custom_command( | ||
OUTPUT ${curl_bundle_BINARY_DIR}/lib/libcurl.a | ||
WORKING_DIRECTORY ${curl_bundle_SOURCE_DIR} | ||
COMMAND | ||
export CC=${CMAKE_C_COMPILER} && | ||
export CXX=${CMAKE_CXX_COMPILER} && | ||
export LD=${CMAKE_LINKER} && | ||
export CFLAGS=-fPIC && | ||
export LIBS=-ldl && | ||
autoreconf -i && sh configure --with-ssl="${OPENSSL_ROOT_DIR}" | ||
--without-libssh2 --enable-static --enable-shared=no --enable-optimize | ||
--disable-manual --without-libidn | ||
--disable-ftp --disable-file --disable-ldap --disable-ldaps | ||
--disable-rtsp --disable-dict --disable-telnet --disable-tftp | ||
--disable-pop3 --disable-imap --disable-smb --disable-smtp | ||
--disable-gopher --without-nghttp2 --enable-http | ||
--with-pic=PIC | ||
--prefix="${curl_bundle_BINARY_DIR}" && make -j 8 && make install) | ||
add_custom_target(libcurl_static_build | ||
DEPENDS ${curl_bundle_BINARY_DIR}/lib/libcurl.a) | ||
add_dependencies(libcurl_static_build openssl102_static_build) | ||
make_directory(${curl_bundle_BINARY_DIR}/include) | ||
endif() | ||
|
||
set(CURL_FOUND yes) | ||
set(CURL_LIBRARY ${curl_bundle_BINARY_DIR}/lib/libcurl.a) | ||
set(CURL_THIRDPARTY_DEPS OpenSSL::SSL OpenSSL::Crypto 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
include(FetchContent) | ||
|
||
if(${BUILD_CURL_FROM_SOURCE}) | ||
message("Add and build standalone libopenssl") | ||
include(FetchContent) | ||
|
||
# make openssl into bundle | ||
FetchContent_Declare( | ||
openssl102 | ||
GIT_REPOSITORY https://github.com/openssl/openssl.git | ||
GIT_TAG OpenSSL_1_0_2-stable | ||
GIT_PROGRESS 1) | ||
|
||
FetchContent_GetProperties(openssl102) | ||
|
||
if(NOT TARGET openssl102_static_build) | ||
if(NOT openssl102_POPULATED) | ||
FetchContent_Populate(openssl102) | ||
endif() | ||
add_custom_command( | ||
OUTPUT ${openssl102_BINARY_DIR}/lib/libssl.a | ||
WORKING_DIRECTORY ${openssl102_SOURCE_DIR} | ||
COMMAND | ||
sh config -fPIC no-unit-test no-shared | ||
--openssldir="${openssl102_BINARY_DIR}" | ||
--prefix="${openssl102_BINARY_DIR}" && make depend -j && make | ||
-j 8 && make install) | ||
add_custom_target(openssl102_static_build | ||
DEPENDS ${openssl102_BINARY_DIR}/lib/libssl.a) | ||
make_directory(${openssl102_BINARY_DIR}/include) | ||
endif() | ||
|
||
set(OPENSSL_FOUND yes) | ||
set(OPENSSL_ROOT_DIR ${openssl102_BINARY_DIR}) | ||
set(OPENSSL_INCLUDE_DIR ${OPENSSL_ROOT_DIR}/include) | ||
set(OPENSSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) | ||
set(OPENSSL_SSL_LIBRARY ${OPENSSL_ROOT_DIR}/lib/libssl.a) | ||
set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) | ||
set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_ROOT_DIR}/lib/libcrypto.a) | ||
set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) | ||
set(OPENSSL_LINK_DIR ${OPENSSL_ROOT_DIR}/lib) | ||
set(OPENSSL_LINK_DIRS ${OPENSSL_LINK_DIR}) | ||
|
||
if(NOT TARGET OpenSSL::SSL) | ||
add_library(OpenSSL::SSL STATIC IMPORTED) | ||
add_dependencies(OpenSSL::SSL openssl102_static_build) | ||
set_target_properties( | ||
OpenSSL::SSL | ||
PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
IMPORTED_LOCATION "${OPENSSL_SSL_LIBRARY}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIRS}" | ||
INTERFACE_LINK_LIBRARIES "${OPENSSL_SSL_LIBRARY}") | ||
endif() | ||
|
||
if(NOT TARGET OpenSSL::Crypto) | ||
add_library(OpenSSL::Crypto STATIC IMPORTED) | ||
add_dependencies(OpenSSL::Crypto openssl102_static_build) | ||
set_target_properties( | ||
OpenSSL::Crypto | ||
PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIRS}" | ||
INTERFACE_LINK_LIBRARIES "${OPENSSL_CRYPTO_LIBRARY}") | ||
endif() | ||
else() | ||
include(${CMAKE_ROOT}/Modules/FindOpenSSL.cmake) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.