diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dbcd309..60d46d7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,17 +64,7 @@ if (BUILD_TESTING) set(CMAKE_BUILD_TYPE "Debug") endif() -include (ExternalProject) -ExternalProject_Add(curl - URL "https://github.com/curl/curl/releases/download/curl-7_85_0/curl-7.85.0.tar.gz" - URL_MD5 "4e9eb4f434e9be889e510f038754d3de" - BUILD_IN_SOURCE 1 - DOWNLOAD_EXTRACT_TIMESTAMP 0 - SOURCE_DIR ${CMAKE_BINARY_DIR}/curl - CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/curl/configure --prefix=${CMAKE_BINARY_DIR} --disable-ftp --disable-ldap --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-smtp --disable-gopher --without-ssl --disable-crypto-auth --without-axtls --without-zlib --disable-rtsp --enable-shared=no --enable-static=yes --with-pic --without-brotli --without-libidn2 - BUILD_COMMAND make -j${MAKE_JOB_COUNT} - INSTALL_COMMAND make install -) +include(cmake/curl.cmake) if (APPLE) find_library(COREFOUNDATION_LIBRARY CoreFoundation) @@ -206,16 +196,13 @@ target_sources(dd_trace_cpp-objects PUBLIC src/datadog/w3c_propagation.h ) -add_dependencies(dd_trace_cpp-objects curl) - -# Make the build libcurl visible. -include_directories(${CMAKE_BINARY_DIR}/include) +add_dependencies(dd_trace_cpp-objects libcurl) # Linking this library requires libcurl and threads. find_package(Threads REQUIRED) target_link_libraries(dd_trace_cpp-objects PUBLIC - ${CMAKE_BINARY_DIR}/lib/libcurl.a + libcurl PUBLIC Threads::Threads ${COVERAGE_LIBRARIES} diff --git a/cmake/curl.cmake b/cmake/curl.cmake new file mode 100644 index 00000000..b9e690aa --- /dev/null +++ b/cmake/curl.cmake @@ -0,0 +1,23 @@ + +include(FetchContent) + +# No need to build curl executable +SET(BUILD_CURL_EXE OFF) +SET(BUILD_SHARED_LIBS OFF) +SET(BUILD_STATIC_LIBS ON) + +# Disables all protocols except HTTP +SET(HTTP_ONLY ON) +SET(CURL_ENABLE_SSL OFF) +SET(CURL_BROTLI OFF) +SET(CURL_ZSTD OFF) +SET(USE_ZLIB OFF) +SET(USE_LIBIDN2 OFF) + +FetchContent_Declare( + curl + URL "https://github.com/curl/curl/releases/download/curl-7_85_0/curl-7.85.0.tar.gz" + URL_MD5 "4e9eb4f434e9be889e510f038754d3de" +) + +FetchContent_MakeAvailable(curl)