Skip to content

Commit febab81

Browse files
Properly support setting DD_TRACE_TRANSPORT to "none" (#172)
1 parent 3a8bcba commit febab81

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

CMakeLists.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ endif ()
2424

2525
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'")
2626

27+
if(DD_TRACE_TRANSPORT STREQUAL "curl")
28+
include(cmake/deps/curl.cmake)
29+
message(STATUS "DD_TRACE_TRANSPORT is set to 'curl', including curl")
30+
elseif(DD_TRACE_TRANSPORT STREQUAL "none")
31+
message(STATUS "DD_TRACE_TRANSPORT is set to 'none', no default transport will be included")
32+
else()
33+
message(FATAL_ERROR "Invalid value for DD_TRACE_TRANSPORT: ${DD_TRACE_TRANSPORT}")
34+
endif()
35+
2736
# Consumer of the library using FetchContent do not need
2837
# to build unit tests, fuzzers and examples.
2938
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
@@ -41,7 +50,6 @@ endif ()
4150

4251
# Linking this library requires threads.
4352
find_package(Threads REQUIRED)
44-
include(cmake/deps/curl.cmake)
4553
include(cmake/deps/json.cmake)
4654
include(cmake/utils.cmake)
4755

@@ -180,6 +188,11 @@ if (BUILD_SHARED_LIBS)
180188
PRIVATE
181189
CURL::libcurl_shared
182190
)
191+
else()
192+
target_sources(dd_trace_cpp-shared
193+
PRIVATE
194+
src/datadog/default_http_client_null.cpp
195+
)
183196
endif ()
184197

185198
add_dependencies(dd_trace_cpp-shared dd_trace_cpp-objects CURL::libcurl_shared)
@@ -218,6 +231,11 @@ if (BUILD_STATIC_LIBS)
218231
PRIVATE
219232
CURL::libcurl_static
220233
)
234+
else()
235+
target_sources(dd_trace_cpp-static
236+
PRIVATE
237+
src/datadog/default_http_client_null.cpp
238+
)
221239
endif ()
222240

223241
add_dependencies(dd_trace_cpp-static dd_trace_cpp-objects)

0 commit comments

Comments
 (0)