-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add temporary libcurl_vendor and use it to get curl
- Loading branch information
Showing
4 changed files
with
123 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
project(libcurl_vendor) | ||
|
||
set(PACKAGE_VERSION "1.0.0") | ||
|
||
macro(build_libcurl) | ||
set(extra_cxx_flags) | ||
set(extra_c_flags) | ||
if(NOT WIN32) | ||
list(APPEND extra_cxx_flags "-std=c++14 -w") | ||
list(APPEND extra_c_flags "-w") | ||
endif() | ||
|
||
set(PKGCONFIG_FOR_OPENSSL) | ||
if(APPLE) | ||
set(PKGCONFIG_FOR_OPENSSL "/usr/local/opt/openssl/lib/pkgconfig") | ||
endif() | ||
|
||
include(ExternalProject) | ||
ExternalProject_Add(curl-7.57.0 | ||
URL https://github.com/curl/curl/releases/download/curl-7_57_0/curl-7.57.0.tar.gz | ||
URL_MD5 c7aab73aaf5e883ca1d7518f93649dc2 | ||
CONFIGURE_COMMAND | ||
<SOURCE_DIR>/configure | ||
CFLAGS=${extra_c_flags} | ||
CXXFLAGS=${extra_cxx_flags} | ||
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PKGCONFIG_FOR_OPENSSL} | ||
--prefix=${CMAKE_CURRENT_BINARY_DIR}/libcurl_install | ||
--with-ssl | ||
BUILD_COMMAND ${MAKE} | ||
INSTALL_COMMAND make install | ||
TIMEOUT 600 | ||
) | ||
|
||
# The external project will install to the build folder, but we'll install that on make install. | ||
install( | ||
DIRECTORY | ||
${CMAKE_CURRENT_BINARY_DIR}/libcurl_install/ | ||
DESTINATION | ||
${CMAKE_INSTALL_PREFIX}/opt/libcurl_vendor | ||
) | ||
endmacro() | ||
|
||
find_package(CURL QUIET) | ||
|
||
if(NOT CURL_FOUND) | ||
# System curl not found, build one locally. | ||
build_libcurl() | ||
endif() | ||
|
||
configure_file(libcurl_vendorConfig.cmake.in | ||
"${PROJECT_BINARY_DIR}/libcurl_vendorConfig.cmake" @ONLY) | ||
configure_file(libcurl_vendorConfig-version.cmake.in | ||
"${PROJECT_BINARY_DIR}/libcurl_vendorConfig-version.cmake" @ONLY) | ||
|
||
install(FILES | ||
"${PROJECT_BINARY_DIR}/libcurl_vendorConfig.cmake" | ||
"${PROJECT_BINARY_DIR}/libcurl_vendorConfig-version.cmake" | ||
DESTINATION share/${PROJECT_NAME}/cmake) |
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,13 @@ | ||
set(PACKAGE_VERSION @PACKAGE_VERSION@) | ||
|
||
set(PACKAGE_VERSION_EXACT False) | ||
set(PACKAGE_VERSION_COMPATIBLE False) | ||
|
||
if("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "${PACKAGE_VERSION}") | ||
set(PACKAGE_VERSION_EXACT True) | ||
set(PACKAGE_VERSION_COMPATIBLE True) | ||
endif() | ||
|
||
if("${PACKAGE_FIND_VERSION}" VERSION_LESS "${PACKAGE_VERSION}") | ||
set(PACKAGE_VERSION_COMPATIBLE True) | ||
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,47 @@ | ||
# prevent multiple inclusion | ||
if(_@PROJECT_NAME@_CONFIG_INCLUDED) | ||
return() | ||
endif() | ||
set(_@PROJECT_NAME@_CONFIG_INCLUDED TRUE) | ||
|
||
# output package information | ||
if(NOT @PROJECT_NAME@_FIND_QUIETLY) | ||
message(STATUS "Found @PROJECT_NAME@: @PACKAGE_VERSION@ (${@PROJECT_NAME@_DIR})") | ||
endif() | ||
|
||
# Look for system curl first. | ||
find_package(CURL QUIET) | ||
|
||
if(NOT CURL_FOUND) | ||
# In this case, the vendor package should have built and installed a local copy. | ||
include(FindPkgConfig) | ||
if(NOT PKG_CONFIG_FOUND) | ||
message(FATAL_ERROR "Could not find pkg-config") | ||
endif() | ||
# Put the local copy's pkgconfig dir on the PKG_CONFIG_PATH. | ||
set(ENV{PKG_CONFIG_PATH} | ||
"$ENV{PKG_CONFIG_PATH}:${@PROJECT_NAME@_DIR}/../../../opt/libcurl_vendor/lib/pkgconfig") | ||
pkg_search_module(CURL REQUIRED libcurl) | ||
endif() | ||
|
||
# message(STATUS "CURL_FOUND: ${CURL_FOUND}") | ||
# message(STATUS "CURL_LIBRARIES: ${CURL_LIBRARIES}") | ||
# message(STATUS "CURL_LIBRARY_DIRS: ${CURL_LIBRARY_DIRS}") | ||
# message(STATUS "CURL_INCLUDE_DIRS: ${CURL_INCLUDE_DIRS}") | ||
|
||
set(libcurl_vendor_LIBRARIES) | ||
foreach(library IN LISTS CURL_LIBRARIES) | ||
message(STATUS "library: ${library}") | ||
if(IS_ABSOLUTE "${library}") | ||
list(APPEND libcurl_vendor_LIBRARIES "${library}") | ||
else() | ||
find_library(library_abs ${library} PATHS "${CURL_LIBRARY_DIRS}" NO_DEFAULT_PATH) | ||
list(APPEND libcurl_vendor_LIBRARIES "${library_abs}") | ||
endif() | ||
endforeach() | ||
set(libcurl_vendor_LIBRARY_DIRS ${CURL_LIBRARY_DIRS}) | ||
set(libcurl_vendor_INCLUDE_DIRS ${CURL_INCLUDE_DIRS}) | ||
|
||
# message(STATUS "libcurl_vendor_LIBRARIES: ${libcurl_vendor_LIBRARIES}") | ||
# message(STATUS "libcurl_vendor_LIBRARY_DIRS: ${libcurl_vendor_LIBRARY_DIRS}") | ||
# message(STATUS "libcurl_vendor_INCLUDE_DIRS: ${libcurl_vendor_INCLUDE_DIRS}") |
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