Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ project(dd-trace-cpp)
option(BUILD_COVERAGE "Build code with code coverage profiling instrumentation" OFF)
option(BUILD_EXAMPLE "Build the example program (example/)" OFF)

set(CMAKE_BUILD_TYPE "RelWithDebInfo")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
Expand All @@ -30,6 +32,13 @@ ExternalProject_Add(curl
INSTALL_COMMAND make install
)

add_library(libcurl INTERFACE IMPORTED GLOBAL)
target_include_directories(libcurl INTERFACE ${CMAKE_BINARY_DIR}/include)

execute_process(COMMAND ${CMAKE_BINARY_DIR}/bin/curl-config --static-libs
OUTPUT_VARIABLE CURL_LINK_OPTS OUTPUT_STRIP_TRAILING_WHITESPACE)
target_link_options(libcurl INTERFACE "SHELL:${CURL_LINK_OPTS}")

if (MSVC)
add_compile_options(/W4 /WX)
else()
Expand Down Expand Up @@ -163,12 +172,15 @@ target_include_directories(dd_trace_cpp PRIVATE ${CMAKE_BINARY_DIR}/include)

# Linking this library requires libcurl and threads.
find_package(Threads REQUIRED)
target_link_libraries(dd_trace_cpp PRIVATE ${CMAKE_BINARY_DIR}/lib/libcurl.a PUBLIC Threads::Threads ${COVERAGE_LIBRARIES})
target_link_libraries(dd_trace_cpp PRIVATE libcurl Threads::Threads ${COVERAGE_LIBRARIES})

# When installing, install the library and its public headers.

install(TARGETS dd_trace_cpp
EXPORT dd_trace_cpp-config
FILE_SET public_headers)
install(EXPORT dd_trace_cpp-config
DESTINATION share/cmake/dd_trace_cpp)

if(BUILD_TESTING)
add_subdirectory(test)
Expand Down
5 changes: 3 additions & 2 deletions src/datadog/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace datadog {
namespace tracing {

using Duration = std::chrono::steady_clock::duration;
using SystemDuration = std::chrono::system_clock::duration;

struct TimePoint {
std::chrono::system_clock::time_point wall =
Expand All @@ -39,11 +40,11 @@ inline Duration operator-(const TimePoint& after, const TimePoint& before) {
}

inline TimePoint operator-(const TimePoint& origin, Duration offset) {
return {origin.wall - offset, origin.tick - offset};
return {origin.wall - std::chrono::duration_cast<SystemDuration>(offset), origin.tick - offset};
}

inline TimePoint& operator+=(TimePoint& self, Duration offset) {
self.wall += offset;
self.wall += std::chrono::duration_cast<SystemDuration>(offset);
self.tick += offset;
return self;
}
Expand Down