From 0b67c935b36366745fa4f7c1a5787557b821c055 Mon Sep 17 00:00:00 2001 From: Damien Mehala Date: Sun, 17 Aug 2025 22:41:46 +0200 Subject: [PATCH 1/2] chore(cmake): overall improvements --- .github/workflows/dev.yml | 8 +- .github/workflows/main.yml | 2 +- .gitignore | 2 + CMakeLists.txt | 219 ++++++++++++++++----- CMakePresets.json | 1 + CheckRequiredCMakeVersion.cmake | 2 +- bin/install-cmake | 2 +- cmake/Catch.cmake | 206 +++++++++++++++++++ cmake/CatchAddTests.cmake | 135 +++++++++++++ cmake/compiler/clang.cmake | 22 +-- cmake/compiler/clang_apple.cmake | 2 +- cmake/compiler/gcc.cmake | 20 +- cmake/compiler/msvc.cmake | 16 +- cmake/dd-trace-cpp-config.cmake.in | 12 ++ cmake/deps/curl.cmake | 41 ++-- cmake/deps/json.cmake | 6 +- examples/baggage/CMakeLists.txt | 2 +- examples/hasher/CMakeLists.txt | 2 +- examples/http-server/proxy/CMakeLists.txt | 2 +- examples/http-server/server/CMakeLists.txt | 2 +- test/CMakeLists.txt | 7 +- test/system-tests/CMakeLists.txt | 4 +- 22 files changed, 592 insertions(+), 123 deletions(-) create mode 100644 cmake/Catch.cmake create mode 100644 cmake/CatchAddTests.cmake create mode 100644 cmake/dd-trace-cpp-config.cmake.in diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index a37b2f5c..8dd1d5fb 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -5,7 +5,7 @@ jobs: format: runs-on: ubuntu-22.04-arm container: - image: datadog/docker-library:dd-trace-cpp-ci-5f5c273-arm64 + image: datadog/docker-library:dd-trace-cpp-ci-23768e9-arm64 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Check format @@ -29,7 +29,7 @@ jobs: needs: format runs-on: ${{ matrix.runner }} container: - image: datadog/docker-library:dd-trace-cpp-ci-5f5c273-${{matrix.docker-arch}} + image: datadog/docker-library:dd-trace-cpp-ci-23768e9-${{matrix.docker-arch}} environment: name: dev permissions: @@ -68,7 +68,7 @@ jobs: docker-arch: amd64 runs-on: ${{ matrix.runner }} container: - image: datadog/docker-library:dd-trace-cpp-ci-5f5c273-${{matrix.docker-arch}} + image: datadog/docker-library:dd-trace-cpp-ci-23768e9-${{matrix.docker-arch}} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Build @@ -144,7 +144,7 @@ jobs: needs: build-linux-cmake runs-on: ubuntu-22.04-arm container: - image: datadog/docker-library:dd-trace-cpp-ci-5f5c273-arm64 + image: datadog/docker-library:dd-trace-cpp-ci-23768e9-arm64 environment: name: dev permissions: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 20fff1c4..522106e3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: needs: call-dev-workflow runs-on: ubuntu-22.04-arm container: - image: datadog/docker-library:dd-trace-cpp-ci-5f5c273-arm64 + image: datadog/docker-library:dd-trace-cpp-ci-23768e9-arm64 env: DURATION_SEC: 300 # 5min steps: diff --git a/.gitignore b/.gitignore index b67dd7c3..31457e72 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ /bazel-* /.build/ +/build/ +/build-*/ /.coverage/ build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index ac20c2c9..e2100d51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,20 @@ # Note: Make sure that this version is the same as that in # "./CheckRequiredCMakeVersion.cmake". -cmake_minimum_required(VERSION 3.24) +cmake_minimum_required(VERSION 3.28...4.0) cmake_policy(SET CMP0077 NEW) -project(dd-trace-cpp) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) +# Get the version of the lib +file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/src/datadog/version.cpp DD_TRACE_VERSION_CPP_CONTENTS REGEX "#define DD_TRACE_VERSION( |_NUM )") +string(REGEX MATCH "#define DD_TRACE_VERSION \"[^\"]*" DD_TRACE_VERSION ${DD_TRACE_VERSION_CPP_CONTENTS}) +string(REGEX REPLACE "[^\"]+\"v" "" DD_TRACE_VERSION ${DD_TRACE_VERSION}) + +project( + dd-trace-cpp + VERSION ${DD_TRACE_VERSION} + LANGUAGES CXX +) option(BUILD_SHARED_LIBS "Build shared libraries" ON) option(BUILD_STATIC_LIBS "Build static libraries" ON) @@ -26,7 +31,6 @@ set(DD_TRACE_TRANSPORT "curl" CACHE STRING "HTTP transport that dd-trace-cpp use 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() @@ -44,18 +48,15 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) option(DD_TRACE_ENABLE_SANITIZE "Build with address sanitizer and undefined behavior sanitizer" OFF) endif() -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "RelWithDebInfo") -endif () +# Include mandatory files +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) # Linking this library requires threads. find_package(Threads REQUIRED) include(cmake/deps/json.cmake) include(cmake/utils.cmake) -file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/src/datadog/version.cpp DD_TRACE_VERSION_CPP_CONTENTS REGEX "#define DD_TRACE_VERSION( |_NUM )") -string(REGEX MATCH "#define DD_TRACE_VERSION \"[^\"]*" DD_TRACE_VERSION ${DD_TRACE_VERSION_CPP_CONTENTS}) -string(REGEX REPLACE "[^\"]+\"" "" DD_TRACE_VERSION ${DD_TRACE_VERSION}) message(STATUS "dd-trace-cpp version=[${DD_TRACE_VERSION}]") unset(DD_TRACE_VERSION_CPP_CONTENTS) @@ -83,7 +84,10 @@ if (DD_TRACE_BUILD_FUZZERS) endif () if (DD_TRACE_BUILD_TESTING) + include(Catch) + enable_testing() add_subdirectory(test) + add_subdirectory(test/system-tests) endif() if (DD_TRACE_BUILD_EXAMPLES) @@ -94,17 +98,68 @@ if (DD_TRACE_BUILD_BENCHMARK) add_subdirectory(benchmark) endif () -add_library(dd_trace_cpp-objects OBJECT) -add_library(dd_trace::obj ALIAS dd_trace_cpp-objects) +add_library(dd-trace-cpp-objects OBJECT) +add_library(dd-trace-cpp::obj ALIAS dd-trace-cpp-objects) -file(GLOB_RECURSE public_header_files ${CMAKE_SOURCE_DIR}/include/*.h) +target_compile_features(dd-trace-cpp-objects + PUBLIC + cxx_std_17 +) -target_sources(dd_trace_cpp-objects +# NOTE: Don't use glob: +# - +# - +target_sources(dd-trace-cpp-objects PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS include - FILES ${public_header_files} + FILES + include/datadog/remote_config/capability.h + include/datadog/remote_config/listener.h + include/datadog/remote_config/product.h + include/datadog/telemetry/configuration.h + include/datadog/telemetry/metrics.h + include/datadog/telemetry/product.h + include/datadog/telemetry/telemetry.h + include/datadog/baggage.h + include/datadog/cerr_logger.h + include/datadog/clock.h + include/datadog/collector.h + include/datadog/config.h + include/datadog/datadog_agent_config.h + include/datadog/dict_reader.h + include/datadog/dict_writer.h + include/datadog/environment.h + include/datadog/error.h + include/datadog/event_scheduler.h + include/datadog/expected.h + include/datadog/http_client.h + include/datadog/id_generator.h + include/datadog/injection_options.h + include/datadog/logger.h + include/datadog/null_collector.h + include/datadog/optional.h + include/datadog/propagation_style.h + include/datadog/rate.h + include/datadog/runtime_id.h + include/datadog/sampling_decision.h + include/datadog/sampling_mechanism.h + include/datadog/sampling_priority.h + include/datadog/span.h + include/datadog/span_config.h + include/datadog/span_defaults.h + include/datadog/span_matcher.h + include/datadog/span_sampler_config.h + include/datadog/string_view.h + include/datadog/trace_id.h + include/datadog/trace_sampler_config.h + include/datadog/trace_segment.h + include/datadog/trace_source.h + include/datadog/tracer.h + include/datadog/tracer_config.h + include/datadog/tracer_signature.h + include/datadog/version.h PRIVATE src/datadog/common/hash.cpp src/datadog/telemetry/configuration.cpp @@ -156,58 +211,75 @@ target_sources(dd_trace_cpp-objects src/datadog/w3c_propagation.cpp ) -# Headers location are different depending of whether we are building -# or installing the library. -target_include_directories(dd_trace_cpp-objects - PUBLIC - $ - $ +target_include_directories(dd-trace-cpp-objects PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/datadog ) -target_link_libraries(dd_trace_cpp-objects +target_link_libraries(dd-trace-cpp-objects PUBLIC Threads::Threads PRIVATE - dd_trace::specs + dd-trace-cpp::specs +) + +set_target_properties(dd-trace-cpp-objects + PROPERTIES + VERIFY_INTERFACE_HEADER_SETS ON + POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} +) + +install( + TARGETS dd-trace-cpp-objects dd-trace-cpp-specs + EXPORT dd-trace-cpp-targets + FILE_SET public_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) # Produce both shared and static versions of the library. if (BUILD_SHARED_LIBS) - add_library(dd_trace_cpp-shared SHARED $) - add_library(dd_trace::shared ALIAS dd_trace_cpp-shared) + add_library(dd-trace-cpp-shared SHARED $) + add_library(dd-trace-cpp::shared ALIAS dd-trace-cpp-shared) - if (DD_TRACE_TRANSPORT STREQUAL "curl") - add_dependencies(dd_trace_cpp-shared CURL::libcurl_shared) + if(DD_TRACE_TRANSPORT STREQUAL "curl") + add_dependencies(dd-trace-cpp-shared CURL::libcurl_shared) - target_sources(dd_trace_cpp-shared + target_sources(dd-trace-cpp-shared PRIVATE src/datadog/curl.cpp src/datadog/default_http_client_curl.cpp ) - target_link_libraries(dd_trace_cpp-shared + target_link_libraries(dd-trace-cpp-shared PRIVATE CURL::libcurl_shared ) + + install( + TARGETS libcurl_shared + EXPORT dd-trace-cpp-targets + ) else() - target_sources(dd_trace_cpp-shared + target_sources(dd-trace-cpp-shared PRIVATE src/datadog/default_http_client_null.cpp ) - endif () + endif() - target_link_libraries(dd_trace_cpp-shared + target_link_libraries(dd-trace-cpp-shared PUBLIC - dd_trace::obj + dd-trace-cpp::obj PRIVATE - dd_trace::specs + dd-trace-cpp::specs + ) + + set_target_properties(dd-trace-cpp-shared + PROPERTIES + OUTPUT_NAME "dd-trace-cpp" ) - install(TARGETS dd_trace_cpp-objects dd_trace_cpp-shared - EXPORT dd_trace_cpp-export - FILE_SET public_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + install( + TARGETS dd-trace-cpp-shared + EXPORT dd-trace-cpp-targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -215,43 +287,82 @@ if (BUILD_SHARED_LIBS) endif () if (BUILD_STATIC_LIBS) - add_library(dd_trace_cpp-static STATIC $) - add_library(dd_trace::static ALIAS dd_trace_cpp-static) + add_library(dd-trace-cpp-static STATIC $) + add_library(dd-trace-cpp::static ALIAS dd-trace-cpp-static) - add_dependencies(dd_trace_cpp-static dd_trace_cpp-objects) + add_dependencies(dd-trace-cpp-static dd-trace-cpp-objects) if (DD_TRACE_TRANSPORT STREQUAL "curl") - add_dependencies(dd_trace_cpp-static CURL::libcurl_static) + add_dependencies(dd-trace-cpp-static CURL::libcurl_static) - target_sources(dd_trace_cpp-static + target_sources(dd-trace-cpp-static PRIVATE src/datadog/curl.cpp src/datadog/default_http_client_curl.cpp ) - target_link_libraries(dd_trace_cpp-static + target_link_libraries(dd-trace-cpp-static PRIVATE CURL::libcurl_static ) + + install( + TARGETS libcurl_static + EXPORT dd-trace-cpp-targets + ) else() - target_sources(dd_trace_cpp-static + target_sources(dd-trace-cpp-static PRIVATE src/datadog/default_http_client_null.cpp ) endif () - target_link_libraries(dd_trace_cpp-static + target_link_libraries(dd-trace-cpp-static PUBLIC - dd_trace::obj + dd-trace-cpp::obj PRIVATE - dd_trace::specs + dd-trace-cpp::specs + ) + + set_target_properties(dd-trace-cpp-static + PROPERTIES + OUTPUT_NAME "dd-trace-cpp" ) - install(TARGETS dd_trace_cpp-objects dd_trace_cpp-static - EXPORT dd_trace_cpp-export - FILE_SET public_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + install( + TARGETS dd-trace-cpp-static + EXPORT dd-trace-cpp-targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} ) endif () + +# install target +write_basic_package_version_file( + "${PROJECT_NAME}-config-version.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in" + ${PROJECT_NAME}-config.cmake + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" + NO_CHECK_REQUIRED_COMPONENTS_MACRO + PATH_VARS CMAKE_INSTALL_INCLUDEDIR +) + +install( + EXPORT dd-trace-cpp-targets + NAMESPACE dd-trace-cpp:: + FILE ${PROJECT_NAME}-targets.cmake + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" +) + +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" +) diff --git a/CMakePresets.json b/CMakePresets.json index 3b3ae05a..99e2381d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -25,6 +25,7 @@ "displayName": "Development", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", "DD_TRACE_ENABLE_SANITIZE": "OFF", "DD_TRACE_BUILD_TESTING": "ON", "DD_TRACE_BUILD_EXAMPLES": "ON", diff --git a/CheckRequiredCMakeVersion.cmake b/CheckRequiredCMakeVersion.cmake index bb412638..e824144e 100644 --- a/CheckRequiredCMakeVersion.cmake +++ b/CheckRequiredCMakeVersion.cmake @@ -8,4 +8,4 @@ # incompatible or something else went wrong. # # Note: Make sure that this version is the same as that in "./CMakeLists.txt". -cmake_minimum_required(VERSION 3.24) +cmake_minimum_required(VERSION 3.28) diff --git a/bin/install-cmake b/bin/install-cmake index 26dadba9..337d4bb8 100755 --- a/bin/install-cmake +++ b/bin/install-cmake @@ -10,7 +10,7 @@ if [ "$(uname)" != Linux ]; then exit 1 fi -VERSION=3.24.2 +VERSION=3.28.6 REPO=$(dirname "$0")/.. # If a suitably recent version of cmake is already installed, then don't bother. diff --git a/cmake/Catch.cmake b/cmake/Catch.cmake new file mode 100644 index 00000000..a3885162 --- /dev/null +++ b/cmake/Catch.cmake @@ -0,0 +1,206 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +Catch +----- + +This module defines a function to help use the Catch test framework. + +The :command:`catch_discover_tests` discovers tests by asking the compiled test +executable to enumerate its tests. This does not require CMake to be re-run +when tests change. However, it may not work in a cross-compiling environment, +and setting test properties is less convenient. + +This command is intended to replace use of :command:`add_test` to register +tests, and will create a separate CTest test for each Catch test case. Note +that this is in some cases less efficient, as common set-up and tear-down logic +cannot be shared by multiple test cases executing in the same instance. +However, it provides more fine-grained pass/fail information to CTest, which is +usually considered as more beneficial. By default, the CTest test name is the +same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. + +.. command:: catch_discover_tests + + Automatically add tests with CTest by querying the compiled test executable + for available tests:: + + catch_discover_tests(target + [TEST_SPEC arg1...] + [EXTRA_ARGS arg1...] + [WORKING_DIRECTORY dir] + [TEST_PREFIX prefix] + [TEST_SUFFIX suffix] + [PROPERTIES name1 value1...] + [TEST_LIST var] + [REPORTER reporter] + [OUTPUT_DIR dir] + [OUTPUT_PREFIX prefix} + [OUTPUT_SUFFIX suffix] + ) + + ``catch_discover_tests`` sets up a post-build command on the test executable + that generates the list of tests by parsing the output from running the test + with the ``--list-test-names-only`` argument. This ensures that the full + list of tests is obtained. Since test discovery occurs at build time, it is + not necessary to re-run CMake when the list of tests changes. + However, it requires that :prop_tgt:`CROSSCOMPILING_EMULATOR` is properly set + in order to function in a cross-compiling environment. + + Additionally, setting properties on tests is somewhat less convenient, since + the tests are not available at CMake time. Additional test properties may be + assigned to the set of tests as a whole using the ``PROPERTIES`` option. If + more fine-grained test control is needed, custom content may be provided + through an external CTest script using the :prop_dir:`TEST_INCLUDE_FILES` + directory property. The set of discovered tests is made accessible to such a + script via the ``_TESTS`` variable. + + The options are: + + ``target`` + Specifies the Catch executable, which must be a known CMake executable + target. CMake will substitute the location of the built executable when + running the test. + + ``TEST_SPEC arg1...`` + Specifies test cases, wildcarded test cases, tags and tag expressions to + pass to the Catch executable with the ``--list-test-names-only`` argument. + + ``EXTRA_ARGS arg1...`` + Any extra arguments to pass on the command line to each test case. + + ``WORKING_DIRECTORY dir`` + Specifies the directory in which to run the discovered test cases. If this + option is not provided, the current binary directory is used. + + ``TEST_PREFIX prefix`` + Specifies a ``prefix`` to be prepended to the name of each discovered test + case. This can be useful when the same test executable is being used in + multiple calls to ``catch_discover_tests()`` but with different + ``TEST_SPEC`` or ``EXTRA_ARGS``. + + ``TEST_SUFFIX suffix`` + Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of + every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may + be specified. + + ``PROPERTIES name1 value1...`` + Specifies additional properties to be set on all tests discovered by this + invocation of ``catch_discover_tests``. + + ``TEST_LIST var`` + Make the list of tests available in the variable ``var``, rather than the + default ``_TESTS``. This can be useful when the same test + executable is being used in multiple calls to ``catch_discover_tests()``. + Note that this variable is only available in CTest. + + ``REPORTER reporter`` + Use the specified reporter when running the test case. The reporter will + be passed to the Catch executable as ``--reporter reporter``. + + ``OUTPUT_DIR dir`` + If specified, the parameter is passed along as + ``--out dir/`` to Catch executable. The actual file name is the + same as the test name. This should be used instead of + ``EXTRA_ARGS --out foo`` to avoid race conditions writing the result output + when using parallel test execution. + + ``OUTPUT_PREFIX prefix`` + May be used in conjunction with ``OUTPUT_DIR``. + If specified, ``prefix`` is added to each output file name, like so + ``--out dir/prefix``. + + ``OUTPUT_SUFFIX suffix`` + May be used in conjunction with ``OUTPUT_DIR``. + If specified, ``suffix`` is added to each output file name, like so + ``--out dir/suffix``. This can be used to add a file extension to + the output e.g. ".xml". + +#]=======================================================================] + +#------------------------------------------------------------------------------ +function(catch_discover_tests TARGET) + cmake_parse_arguments( + "" + "" + "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX" + "TEST_SPEC;EXTRA_ARGS;PROPERTIES" + ${ARGN} + ) + + if(NOT _WORKING_DIRECTORY) + set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endif() + if(NOT _TEST_LIST) + set(_TEST_LIST ${TARGET}_TESTS) + endif() + + ## Generate a unique name based on the extra arguments + string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS} ${_REPORTER} ${_OUTPUT_DIR} ${_OUTPUT_PREFIX} ${_OUTPUT_SUFFIX}") + string(SUBSTRING ${args_hash} 0 7 args_hash) + + # Define rule to generate test list for aforementioned test executable + set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake") + set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake") + get_property(crosscompiling_emulator + TARGET ${TARGET} + PROPERTY CROSSCOMPILING_EMULATOR + ) + add_custom_command( + TARGET ${TARGET} POST_BUILD + BYPRODUCTS "${ctest_tests_file}" + COMMAND "${CMAKE_COMMAND}" + -D "TEST_TARGET=${TARGET}" + -D "TEST_EXECUTABLE=$" + -D "TEST_EXECUTOR=${crosscompiling_emulator}" + -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}" + -D "TEST_SPEC=${_TEST_SPEC}" + -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}" + -D "TEST_PROPERTIES=${_PROPERTIES}" + -D "TEST_PREFIX=${_TEST_PREFIX}" + -D "TEST_SUFFIX=${_TEST_SUFFIX}" + -D "TEST_LIST=${_TEST_LIST}" + -D "TEST_REPORTER=${_REPORTER}" + -D "TEST_OUTPUT_DIR=${_OUTPUT_DIR}" + -D "TEST_OUTPUT_PREFIX=${_OUTPUT_PREFIX}" + -D "TEST_OUTPUT_SUFFIX=${_OUTPUT_SUFFIX}" + -D "CTEST_FILE=${ctest_tests_file}" + -P "${_CATCH_DISCOVER_TESTS_SCRIPT}" + VERBATIM + ) + + file(WRITE "${ctest_include_file}" + "if(EXISTS \"${ctest_tests_file}\")\n" + " include(\"${ctest_tests_file}\")\n" + "else()\n" + " add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n" + "endif()\n" + ) + + if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") + # Add discovered tests to directory TEST_INCLUDE_FILES + set_property(DIRECTORY + APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}" + ) + else() + # Add discovered tests as directory TEST_INCLUDE_FILE if possible + get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET) + if (NOT ${test_include_file_set}) + set_property(DIRECTORY + PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}" + ) + else() + message(FATAL_ERROR + "Cannot set more than one TEST_INCLUDE_FILE" + ) + endif() + endif() + +endfunction() + +############################################################################### + +set(_CATCH_DISCOVER_TESTS_SCRIPT + ${CMAKE_CURRENT_LIST_DIR}/CatchAddTests.cmake + CACHE INTERNAL "Catch2 full path to CatchAddTests.cmake helper file" +) diff --git a/cmake/CatchAddTests.cmake b/cmake/CatchAddTests.cmake new file mode 100644 index 00000000..184e506e --- /dev/null +++ b/cmake/CatchAddTests.cmake @@ -0,0 +1,135 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +set(prefix "${TEST_PREFIX}") +set(suffix "${TEST_SUFFIX}") +set(spec ${TEST_SPEC}) +set(extra_args ${TEST_EXTRA_ARGS}) +set(properties ${TEST_PROPERTIES}) +set(reporter ${TEST_REPORTER}) +set(output_dir ${TEST_OUTPUT_DIR}) +set(output_prefix ${TEST_OUTPUT_PREFIX}) +set(output_suffix ${TEST_OUTPUT_SUFFIX}) +set(script) +set(suite) +set(tests) + +function(add_command NAME) + set(_args "") + # use ARGV* instead of ARGN, because ARGN splits arrays into multiple arguments + math(EXPR _last_arg ${ARGC}-1) + foreach(_n RANGE 1 ${_last_arg}) + set(_arg "${ARGV${_n}}") + if(_arg MATCHES "[^-./:a-zA-Z0-9_]") + set(_args "${_args} [==[${_arg}]==]") # form a bracket_argument + else() + set(_args "${_args} ${_arg}") + endif() + endforeach() + set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE) +endfunction() + +# Run test executable to get list of available tests +if(NOT EXISTS "${TEST_EXECUTABLE}") + message(FATAL_ERROR + "Specified test executable '${TEST_EXECUTABLE}' does not exist" + ) +endif() +execute_process( + COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-names-only + OUTPUT_VARIABLE output + RESULT_VARIABLE result + WORKING_DIRECTORY "${TEST_WORKING_DIR}" +) +# Catch --list-test-names-only reports the number of tests, so 0 is... surprising +if(${result} EQUAL 0) + message(WARNING + "Test executable '${TEST_EXECUTABLE}' contains no tests!\n" + ) +elseif(${result} LESS 0) + message(FATAL_ERROR + "Error running test executable '${TEST_EXECUTABLE}':\n" + " Result: ${result}\n" + " Output: ${output}\n" + ) +endif() + +string(REPLACE "\n" ";" output "${output}") + +# Run test executable to get list of available reporters +execute_process( + COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-reporters + OUTPUT_VARIABLE reporters_output + RESULT_VARIABLE reporters_result + WORKING_DIRECTORY "${TEST_WORKING_DIR}" +) +if(${reporters_result} EQUAL 0) + message(WARNING + "Test executable '${TEST_EXECUTABLE}' contains no reporters!\n" + ) +elseif(${reporters_result} LESS 0) + message(FATAL_ERROR + "Error running test executable '${TEST_EXECUTABLE}':\n" + " Result: ${reporters_result}\n" + " Output: ${reporters_output}\n" + ) +endif() +string(FIND "${reporters_output}" "${reporter}" reporter_is_valid) +if(reporter AND ${reporter_is_valid} EQUAL -1) + message(FATAL_ERROR + "\"${reporter}\" is not a valid reporter!\n" + ) +endif() + +# Prepare reporter +if(reporter) + set(reporter_arg "--reporter ${reporter}") +endif() + +# Prepare output dir +if(output_dir AND NOT IS_ABSOLUTE ${output_dir}) + set(output_dir "${TEST_WORKING_DIR}/${output_dir}") + if(NOT EXISTS ${output_dir}) + file(MAKE_DIRECTORY ${output_dir}) + endif() +endif() + +# Parse output +foreach(line ${output}) + set(test ${line}) + # Escape characters in test case names that would be parsed by Catch2 + set(test_name ${test}) + foreach(char , [ ]) + string(REPLACE ${char} "\\${char}" test_name ${test_name}) + endforeach(char) + # ...add output dir + if(output_dir) + string(REGEX REPLACE "[^A-Za-z0-9_]" "_" test_name_clean ${test_name}) + set(output_dir_arg "--out ${output_dir}/${output_prefix}${test_name_clean}${output_suffix}") + endif() + + # ...and add to script + add_command(add_test + "${prefix}${test}${suffix}" + ${TEST_EXECUTOR} + "${TEST_EXECUTABLE}" + "${test_name}" + ${extra_args} + "${reporter_arg}" + "${output_dir_arg}" + ) + add_command(set_tests_properties + "${prefix}${test}${suffix}" + PROPERTIES + WORKING_DIRECTORY "${TEST_WORKING_DIR}" + ${properties} + ) + list(APPEND tests "${prefix}${test}${suffix}") +endforeach() + +# Create a list of all discovered tests, which users may use to e.g. set +# properties on the tests +add_command(set ${TEST_LIST} ${tests}) + +# Write CTest script +file(WRITE "${CTEST_FILE}" "${script}") diff --git a/cmake/compiler/clang.cmake b/cmake/compiler/clang.cmake index c726e637..b812d02b 100644 --- a/cmake/compiler/clang.cmake +++ b/cmake/compiler/clang.cmake @@ -2,10 +2,10 @@ # It provides a convenient way to apply these options to multiple targets. # ---- # Usage: Link `dd_trace_cpp-specs` to targets using target_link_libraries. -add_library(dd_trace_cpp-specs INTERFACE) -add_library(dd_trace::specs ALIAS dd_trace_cpp-specs) +add_library(dd-trace-cpp-specs INTERFACE) +add_library(dd-trace-cpp::specs ALIAS dd-trace-cpp-specs) -target_compile_options(dd_trace_cpp-specs +target_compile_options(dd-trace-cpp-specs INTERFACE -Wall -Wextra @@ -27,7 +27,7 @@ target_compile_options(dd_trace_cpp-specs ) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 16) - target_compile_options(dd_trace_cpp-specs + target_compile_options(dd-trace-cpp-specs INTERFACE -fstrict-flex-arrays=3 ) @@ -35,19 +35,19 @@ endif () if (CMAKE_BUILD_TYPE STREQUAL "Release|RelWithDebInfo") # -ftrivial-auto-var-init can interfere with other tools - target_compile_options(dd_trace_cpp-specs + target_compile_options(dd-trace-cpp-specs INTERFACE -ftrivial-auto-var-init=zero ) endif () function(add_sanitizers) - target_compile_options(dd_trace_cpp-specs + target_compile_options(dd-trace-cpp-specs INTERFACE -fsanitize=address,undefined ) - target_link_libraries(dd_trace_cpp-specs + target_link_libraries(dd-trace-cpp-specs INTERFACE -fsanitize=address,undefined ) @@ -59,7 +59,7 @@ if (DD_TRACE_ENABLE_COVERAGE) message(FATAL_ERROR "gcov not found. Cannot build with -DDD_TRACE_ENABLE_COVERAGE") endif () - target_compile_options(dd_trace_cpp-specs + target_compile_options(dd-trace-cpp-specs INTERFACE -g -O0 @@ -67,7 +67,7 @@ if (DD_TRACE_ENABLE_COVERAGE) -ftest-coverage ) - target_link_libraries(dd_trace_cpp-specs + target_link_libraries(dd-trace-cpp-specs INTERFACE -fprofile-arcs ) @@ -80,12 +80,12 @@ endif() if (DD_TRACE_BUILD_FUZZERS) add_sanitizers() - target_compile_options(dd_trace_cpp-specs + target_compile_options(dd-trace-cpp-specs INTERFACE -fsanitize=fuzzer ) - target_link_libraries(dd_trace_cpp-specs + target_link_libraries(dd-trace-cpp-specs INTERFACE -fsanitize=fuzzer ) diff --git a/cmake/compiler/clang_apple.cmake b/cmake/compiler/clang_apple.cmake index 3d4b0b22..9f58817e 100644 --- a/cmake/compiler/clang_apple.cmake +++ b/cmake/compiler/clang_apple.cmake @@ -3,7 +3,7 @@ include(cmake/compiler/clang.cmake) find_library(COREFOUNDATION_LIBRARY CoreFoundation) find_library(SYSTEMCONFIGURATION_LIBRARY SystemConfiguration) -target_link_libraries(dd_trace_cpp-specs +target_link_libraries(dd-trace-cpp-specs INTERFACE ${COREFOUNDATION_LIBRARY} ${SYSTEMCONFIGURATION_LIBRARY} diff --git a/cmake/compiler/gcc.cmake b/cmake/compiler/gcc.cmake index 64cefe8f..c0b02b7c 100644 --- a/cmake/compiler/gcc.cmake +++ b/cmake/compiler/gcc.cmake @@ -2,10 +2,10 @@ # It provides a convenient way to apply these options to multiple targets. # ---- # Usage: Link `dd_trace_cpp-specs` to targets using target_link_libraries. -add_library(dd_trace_cpp-specs INTERFACE) -add_library(dd_trace::specs ALIAS dd_trace_cpp-specs) +add_library(dd-trace-cpp-specs INTERFACE) +add_library(dd-trace-cpp::specs ALIAS dd-trace-cpp-specs) -target_compile_options(dd_trace_cpp-specs +target_compile_options(dd-trace-cpp-specs INTERFACE -Wall -Wextra @@ -27,13 +27,13 @@ target_compile_options(dd_trace_cpp-specs -pedantic ) -target_link_options(dd_trace_cpp-specs +target_link_options(dd-trace-cpp-specs INTERFACE -Wl,-z,noexecstack ) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 13) - target_compile_options(dd_trace_cpp-specs + target_compile_options(dd-trace-cpp-specs INTERFACE -Wbidi-chars=any -fstrict-flex-arrays=3 @@ -41,7 +41,7 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 13) if (CMAKE_BUILD_TYPE STREQUAL "Release|RelWithDebInfo") # -ftrivial-auto-var-init can interfere with other tools - target_compile_options(dd_trace_cpp-specs + target_compile_options(dd-trace-cpp-specs INTERFACE -ftrivial-auto-var-init=zero ) @@ -54,24 +54,24 @@ if (DD_TRACE_ENABLE_COVERAGE) message(FATAL_ERROR "gcov not found. Cannot build with -DDD_TRACE_ENABLE_COVERAGE") endif () - target_compile_options(dd_trace_cpp-specs + target_compile_options(dd-trace-cpp-specs INTERFACE -g -O0 -fprofile-arcs -ftest-coverage ) - target_link_libraries(dd_trace_cpp-specs + target_link_libraries(dd-trace-cpp-specs INTERFACE -fprofile-arcs ) endif() if (DD_TRACE_ENABLE_SANITIZE) - target_compile_options(dd_trace_cpp-specs + target_compile_options(dd-trace-cpp-specs INTERFACE -fsanitize=address,undefined ) - target_link_libraries(dd_trace_cpp-specs + target_link_libraries(dd-trace-cpp-specs INTERFACE -fsanitize=address,undefined ) diff --git a/cmake/compiler/msvc.cmake b/cmake/compiler/msvc.cmake index f20e3a20..54ea7d38 100644 --- a/cmake/compiler/msvc.cmake +++ b/cmake/compiler/msvc.cmake @@ -29,9 +29,9 @@ set(WINDOWS_EXPORT_ALL_SYMBOLS ON) # This target interface encapsulates compiler and linker options for the project. # It provides a convenient way to apply these options to multiple targets. # ---- -# Usage: Link `dd_trace_cpp-specs` to targets using target_link_libraries. -add_library(dd_trace_cpp-specs INTERFACE) -add_library(dd_trace::specs ALIAS dd_trace_cpp-specs) +# Usage: Link `dd-trace-cpp-specs` to targets using target_link_libraries. +add_library(dd-trace-cpp-specs INTERFACE) +add_library(dd-trace-cpp::specs ALIAS dd-trace-cpp-specs) if (DD_TRACE_STATIC_CRT) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") @@ -39,7 +39,7 @@ if (DD_TRACE_STATIC_CRT) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") endif () -target_compile_options(dd_trace_cpp-specs +target_compile_options(dd-trace-cpp-specs INTERFACE /W4 /wd4706 @@ -47,13 +47,13 @@ target_compile_options(dd_trace_cpp-specs /D_WIN32_WINNT=${win_ver} ) -target_link_options(dd_trace_cpp-specs +target_link_options(dd-trace-cpp-specs INTERFACE ws2_32.lib ) if (CMAKE_BUILD_TYPE STREQUAL "Debug|RelWithDebInfo") - target_compile_options(dd_trace_cpp-specs + target_compile_options(dd-trace-cpp-specs INTERFACE # Embedded debug information in binaries (no pdb) /Z7 @@ -69,12 +69,12 @@ if (DD_TRACE_BUILD_FUZZERS) endif () if (DD_TRACE_ENABLE_SANITIZE) - target_compile_options(dd_trace_cpp-specs + target_compile_options(dd-trace-cpp-specs INTERFACE /fsanitize=address /RTC1 ) - target_link_options(dd_trace_cpp-specs + target_link_options(dd-trace-cpp-specs INTERFACE /fsanitize=address ) diff --git a/cmake/dd-trace-cpp-config.cmake.in b/cmake/dd-trace-cpp-config.cmake.in new file mode 100644 index 00000000..7ed689a2 --- /dev/null +++ b/cmake/dd-trace-cpp-config.cmake.in @@ -0,0 +1,12 @@ +@PACKAGE_INIT@ +include(CMakeFindDependencyMacro) + +set_and_check(dd-trace-cpp_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") + +find_dependency(Threads) + +if(DD_TRACE_TRANSPORT STREQUAL "curl") + find_dependency(CURL) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/dd-trace-cpp-targets.cmake") diff --git a/cmake/deps/curl.cmake b/cmake/deps/curl.cmake index 8fcc8dfd..132f6bfa 100644 --- a/cmake/deps/curl.cmake +++ b/cmake/deps/curl.cmake @@ -1,35 +1,36 @@ include(FetchContent) # No need to build curl executable -SET(BUILD_CURL_EXE OFF) -set(BUILD_LIBCURL_DOCS OFF) -set(BUILD_MISC_DOCS OFF) +SET(BUILD_CURL_EXE OFF CACHE BOOL "" FORCE) +set(BUILD_LIBCURL_DOCS OFF CACHE BOOL "" FORCE) +set(BUILD_MISC_DOCS OFF CACHE BOOL "" FORCE) # Disable all protocols except HTTP -SET(HTTP_ONLY ON) +SET(HTTP_ONLY ON CACHE BOOL "" FORCE) # Disable curl features -SET(USE_ZLIB OFF) -SET(USE_LIBIDN2 OFF) -SET(CURL_ENABLE_SSL OFF) -SET(CURL_BROTLI OFF) -SET(CURL_ZSTD OFF) -SET(CURL_ZLIB OFF) -SET(CURL_USE_LIBSSH2 OFF) -SET(CURL_USE_LIBPSL OFF) -SET(CURL_DISABLE_HSTS ON) +SET(USE_ZLIB OFF CACHE BOOL "" FORCE) +SET(USE_LIBIDN2 OFF CACHE BOOL "" FORCE) +SET(CURL_ENABLE_SSL OFF CACHE BOOL "" FORCE) +SET(CURL_BROTLI OFF CACHE BOOL "" FORCE) +SET(CURL_ZSTD OFF CACHE BOOL "" FORCE) +SET(CURL_ZLIB OFF CACHE BOOL "" FORCE) +SET(CURL_USE_LIBSSH2 OFF CACHE BOOL "" FORCE) +SET(CURL_USE_LIBPSL OFF CACHE BOOL "" FORCE) +SET(CURL_DISABLE_HSTS ON CACHE BOOL "" FORCE) set(CURL_CA_PATH "none") -set(CURL_CA_PATH_SET FALSE) -set(CURL_DISABLE_INSTALL ON) -set(CURL_DISABLE_ALTSVC ON) -set(CURL_DISABLE_SRP ON) +set(CURL_CA_PATH_SET FALSE CACHE BOOL "" FORCE) +set(CURL_DISABLE_INSTALL ON CACHE BOOL "" FORCE) +set(CURL_DISABLE_ALTSVC ON CACHE BOOL "" FORCE) +set(CURL_DISABLE_SRP ON CACHE BOOL "" FORCE) -set(SHARE_LIB_OBJECT ON) +set(SHARE_LIB_OBJECT ON CACHE BOOL "" FORCE) FetchContent_Declare( - curl + CURL URL "https://github.com/curl/curl/releases/download/curl-8_8_0/curl-8.8.0.tar.gz" URL_MD5 "2300048f61e6196678281a8612a873ef" + FIND_PACKAGE_ARGS NAMES CURL ) -FetchContent_MakeAvailable(curl) +FetchContent_MakeAvailable(CURL) diff --git a/cmake/deps/json.cmake b/cmake/deps/json.cmake index 1007d48f..890826b9 100644 --- a/cmake/deps/json.cmake +++ b/cmake/deps/json.cmake @@ -1,7 +1,7 @@ include(FetchContent) -set(JSON_BuildTests OFF) -set(JSON_Install OFF) +set(JSON_BuildTests OFF CACHE BOOL "" FORCE) +set(JSON_Install OFF CACHE BOOL "" FORCE) FetchContent_Declare(nlohmann_json URL https://github.com/nlohmann/json/archive/refs/tags/v3.12.0.tar.gz @@ -9,4 +9,4 @@ FetchContent_Declare(nlohmann_json FIND_PACKAGE_ARGS NAMES nlohmann_json ) -FetchContent_MakeAvailable(nlohmann_json) \ No newline at end of file +FetchContent_MakeAvailable(nlohmann_json) diff --git a/examples/baggage/CMakeLists.txt b/examples/baggage/CMakeLists.txt index 5b36932c..a1f7cf9b 100644 --- a/examples/baggage/CMakeLists.txt +++ b/examples/baggage/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(baggage-example main.cpp) -target_link_libraries(baggage-example dd_trace_cpp-static) +target_link_libraries(baggage-example dd-trace-cpp::static) diff --git a/examples/hasher/CMakeLists.txt b/examples/hasher/CMakeLists.txt index de3a8242..5fea66f8 100644 --- a/examples/hasher/CMakeLists.txt +++ b/examples/hasher/CMakeLists.txt @@ -1,4 +1,4 @@ add_executable(hasher-example hasher.cpp) set_target_properties(hasher-example PROPERTIES OUTPUT_NAME example) -target_link_libraries(hasher-example dd_trace_cpp-static) +target_link_libraries(hasher-example dd-trace-cpp::static) diff --git a/examples/http-server/proxy/CMakeLists.txt b/examples/http-server/proxy/CMakeLists.txt index 79e300cf..bf39e6ae 100644 --- a/examples/http-server/proxy/CMakeLists.txt +++ b/examples/http-server/proxy/CMakeLists.txt @@ -2,6 +2,6 @@ add_executable(http-proxy-example proxy.cpp) target_include_directories(http-proxy-example PRIVATE ../common) -target_link_libraries(http-proxy-example dd_trace_cpp-static) +target_link_libraries(http-proxy-example dd-trace-cpp::static) install(TARGETS http-proxy-example) diff --git a/examples/http-server/server/CMakeLists.txt b/examples/http-server/server/CMakeLists.txt index e87f93df..69c2d038 100644 --- a/examples/http-server/server/CMakeLists.txt +++ b/examples/http-server/server/CMakeLists.txt @@ -2,6 +2,6 @@ add_executable(http-server-example server.cpp) target_include_directories(http-server-example PRIVATE ../common) -target_link_libraries(http-server-example dd_trace_cpp-static) +target_link_libraries(http-server-example dd-trace-cpp::static) install(TARGETS http-server-example) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6415f792..c4754be1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -61,8 +61,8 @@ target_compile_definitions(tests target_link_libraries(tests PRIVATE - dd_trace_cpp-static - dd_trace::specs + dd-trace-cpp::static + dd-trace-cpp::specs ) if(DD_TRACE_TRANSPORT STREQUAL "curl") @@ -74,4 +74,5 @@ if(DD_TRACE_TRANSPORT STREQUAL "curl") ) endif() -add_subdirectory(system-tests) +catch_discover_tests(tests) + diff --git a/test/system-tests/CMakeLists.txt b/test/system-tests/CMakeLists.txt index 42b1f5b5..a6866a73 100644 --- a/test/system-tests/CMakeLists.txt +++ b/test/system-tests/CMakeLists.txt @@ -15,8 +15,8 @@ target_include_directories(parametric-http-server target_link_libraries(parametric-http-server PRIVATE - dd_trace_cpp-static - dd_trace::specs + dd-trace-cpp::static + dd-trace-cpp::specs nlohmann_json::nlohmann_json ) From 351927f94f43ce0af7a12a109fd0dc0d8bbce0fe Mon Sep 17 00:00:00 2001 From: Damien Mehala Date: Tue, 14 Oct 2025 14:25:29 +0200 Subject: [PATCH 2/2] update benchmark target --- benchmark/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 2571e222..59ea4d9e 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -23,6 +23,6 @@ target_include_directories(dd_trace_cpp-benchmark target_link_libraries(dd_trace_cpp-benchmark PRIVATE benchmark::benchmark - dd_trace::static + dd-trace-cpp::static nlohmann_json::nlohmann_json )