From 7f7acd1f0899e8abc48b225124ae0f96e634322e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Sun, 1 Dec 2024 12:37:20 +0000 Subject: [PATCH] Properly support setting DD_TRACE_TRANSPORT to "none" --- CMakeLists.txt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f947b3e..419cb0af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,15 @@ endif () set(DD_TRACE_TRANSPORT "curl" CACHE STRING "HTTP transport that dd-trace-cpp uses to communicate with the Datadog Agent, can be either 'none' or 'curl'") +if(DD_TRACE_TRANSPORT STREQUAL "curl") + include(cmake/deps/curl.cmake) + message(STATUS "DD_TRACE_TRANSPORT is set to 'curl', including curl") +elseif(DD_TRACE_TRANSPORT STREQUAL "none") + message(STATUS "DD_TRACE_TRANSPORT is set to 'none', no default transport will be included") +else() + message(FATAL_ERROR "Invalid value for DD_TRACE_TRANSPORT: ${DD_TRACE_TRANSPORT}") +endif() + # Consumer of the library using FetchContent do not need # to build unit tests, fuzzers and examples. if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) @@ -41,7 +50,6 @@ endif () # Linking this library requires threads. find_package(Threads REQUIRED) -include(cmake/deps/curl.cmake) include(cmake/deps/json.cmake) include(cmake/utils.cmake) @@ -180,6 +188,11 @@ if (BUILD_SHARED_LIBS) PRIVATE CURL::libcurl_shared ) + else() + target_sources(dd_trace_cpp-shared + PRIVATE + src/datadog/default_http_client_null.cpp + ) endif () add_dependencies(dd_trace_cpp-shared dd_trace_cpp-objects CURL::libcurl_shared) @@ -218,6 +231,11 @@ if (BUILD_STATIC_LIBS) PRIVATE CURL::libcurl_static ) + else() + target_sources(dd_trace_cpp-static + PRIVATE + src/datadog/default_http_client_null.cpp + ) endif () add_dependencies(dd_trace_cpp-static dd_trace_cpp-objects)