From de4b11e8beea8fd7a25711bc2de2aa8fc4e00aca Mon Sep 17 00:00:00 2001 From: Kevin Sucre Date: Fri, 25 Aug 2023 10:37:25 -0600 Subject: [PATCH 01/12] use cpm --- .gitignore | 1 + CMakeLists.txt | 43 +++++++++++++++++++++++++++-------- cmake/CPM.cmake | 33 +++++++++++++++++++++++++++ include/datadog/opentracing.h | 2 +- 4 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 cmake/CPM.cmake diff --git a/.gitignore b/.gitignore index af46e411..6e59f507 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ # Build folder .build/ +build/ # Locally installed dependencies deps/ diff --git a/CMakeLists.txt b/CMakeLists.txt index fc121ca5..faa9ec7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ set(SOVERSION 0) # * CMAKE_INSTALL_INCLUDEDIR include(GNUInstallDirs) -option(BUILD_SHARED "Builds shared library" ON) -option(BUILD_STATIC "Builds static library" OFF) +option(BUILD_SHARED "Builds shared library" OFF) +option(BUILD_STATIC "Builds static library" ON) option(BUILD_OBJECT "Builds objects for use in another project" OFF) option(BUILD_PLUGIN "Builds plugin (requires gcc and not macos)" OFF) option(BUILD_TESTING "Builds tests, also enables BUILD_SHARED" OFF) @@ -25,7 +25,7 @@ endif() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "RelWithDebInfo") endif() -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 20) # Includes include_directories(SYSTEM 3rd_party/include deps/include) @@ -35,10 +35,32 @@ include_directories(include) set(CMAKE_LIBRARY_PATH deps/lib) # Dependencies -find_path(OPENTRACING_INCLUDE_DIR NAMES opentracing/tracer.h) -find_library(OPENTRACING_LIB opentracing) -find_library(MSGPACK_LIB msgpack) -find_package(CURL) +include(cmake/CPM.cmake) +set(CPM_USE_LOCAL_PACKAGES ON) +CPMAddPackage("gh:catchorg/Catch2@3.3.2") +CPMAddPackage("gh:CLIUtils/CLI11@2.3.2") +CPMAddPackage( + NAME opentelemetry-cpp + GITHUB_REPOSITORY maztheman/opentelemetry-cpp + GIT_TAG main + OPTIONS + "WITH_STL ON" "WITH_OPENTRACING ON" "BUILD_TESTING OFF" "BUILD_STATIC_LIBS ON" +) +CPMAddPackage("gh:curl/curl#curl-8_2_1") +CPMAddPackage( + NAME msgpack-c + GITHUB_REPOSITORY msgpack/msgpack-c + GIT_TAG cpp-6.1.0 + OPTIONS "MSGPACK_CXX20 ON" +) +CPMAddPackage( + NAME nlohmann_json + VERSION 3.11.2 + GITHUB_REPOSITORY nlohmann/json + GITHUB_TAG v3.11.2 + OPTIONS + "JSON_BuildTests OFF" +) find_package(Threads REQUIRED) # Code Sanitizers @@ -50,7 +72,7 @@ install(DIRECTORY include/datadog DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) file(GLOB DD_OPENTRACING_SOURCES "src/*.cpp") message(STATUS "Compiler ID: ${CMAKE_CXX_COMPILER_ID}") if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - add_compile_options(-Wall -Wextra -Werror -pedantic -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast -std=c++14) + add_compile_options(-Wall -Wextra -pedantic) if(BUILD_COVERAGE) add_compile_options(-g -O0 -fprofile-arcs -ftest-coverage) endif() @@ -64,7 +86,10 @@ endif() if(BUILD_COVERAGE) set(COVERAGE_LIBRARIES gcov) endif() -set(DATADOG_LINK_LIBRARIES ${OPENTRACING_LIB} ${CURL_LIBRARIES} Threads::Threads ${COVERAGE_LIBRARIES}) +set(DATADOG_LINK_LIBRARIES opentelemetry_opentracing_shim + + msgpack-cxx + libcurl Threads::Threads nlohmann_json::nlohmann_json Catch2::Catch2WithMain CLI11::CLI11 ${COVERAGE_LIBRARIES}) ## Shared lib if(BUILD_SHARED) diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake new file mode 100644 index 00000000..f49d7434 --- /dev/null +++ b/cmake/CPM.cmake @@ -0,0 +1,33 @@ +set(CPM_DOWNLOAD_VERSION 0.38.2) + +if(CPM_SOURCE_CACHE) + set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +elseif(DEFINED ENV{CPM_SOURCE_CACHE}) + set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +else() + set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +endif() + +# Expand relative path. This is important if the provided path contains a tilde (~) +get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) + +function(download_cpm) + message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") + file(DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} + ) +endfunction() + +if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) + download_cpm() +else() + # resume download if it previously failed + file(READ ${CPM_DOWNLOAD_LOCATION} check) + if("${check}" STREQUAL "") + download_cpm() + endif() + unset(check) +endif() + +include(${CPM_DOWNLOAD_LOCATION}) diff --git a/include/datadog/opentracing.h b/include/datadog/opentracing.h index b4f6bd81..b1a390bd 100644 --- a/include/datadog/opentracing.h +++ b/include/datadog/opentracing.h @@ -16,7 +16,7 @@ #define DD_OPENTRACING_API #endif // _MSC_VER -#include +#include #include #include From 043b32acc5b7232340f35bb2baaa19f3910b988a Mon Sep 17 00:00:00 2001 From: Kevin Sucre Date: Fri, 25 Aug 2023 10:55:45 -0600 Subject: [PATCH 02/12] Make this repo more FetchContent-able --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index faa9ec7b..a9cdfba3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ CPMAddPackage( find_package(Threads REQUIRED) # Code Sanitizers -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/3rd_party/sanitizers-cmake" ${CMAKE_MODULE_PATH}) +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/3rd_party/sanitizers-cmake" ${CMAKE_MODULE_PATH}) find_package(Sanitizers) # Code From b0ce19411aed86c7f5264325183292ce4cc13050 Mon Sep 17 00:00:00 2001 From: Kevin Sucre Date: Mon, 28 Aug 2023 10:21:03 -0600 Subject: [PATCH 03/12] use cpm, other minor fixes --- CMakeLists.txt | 63 ++++++++++++++-------------------------------- Dependencies.cmake | 31 +++++++++++++++++++++++ 2 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 Dependencies.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a9cdfba3..21dd4b86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.14) -project(dd-opentracing-cpp) +project(dd-opentracing-cpp CXX C) set(SOVERSION 0) @@ -10,7 +10,7 @@ set(SOVERSION 0) # * CMAKE_INSTALL_INCLUDEDIR include(GNUInstallDirs) -option(BUILD_SHARED "Builds shared library" OFF) +option(BUILD_SHARED "Builds shared library" ON) option(BUILD_STATIC "Builds static library" ON) option(BUILD_OBJECT "Builds objects for use in another project" OFF) option(BUILD_PLUGIN "Builds plugin (requires gcc and not macos)" OFF) @@ -25,59 +25,33 @@ endif() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "RelWithDebInfo") endif() -set(CMAKE_CXX_STANDARD 20) -# Includes -include_directories(SYSTEM 3rd_party/include deps/include) -include_directories(include) +set(CMAKE_CXX_STANDARD 20) -# Libraries -set(CMAKE_LIBRARY_PATH deps/lib) +include(Dependencies.cmake) +add_external_dependencies() # Dependencies -include(cmake/CPM.cmake) -set(CPM_USE_LOCAL_PACKAGES ON) -CPMAddPackage("gh:catchorg/Catch2@3.3.2") -CPMAddPackage("gh:CLIUtils/CLI11@2.3.2") -CPMAddPackage( - NAME opentelemetry-cpp - GITHUB_REPOSITORY maztheman/opentelemetry-cpp - GIT_TAG main - OPTIONS - "WITH_STL ON" "WITH_OPENTRACING ON" "BUILD_TESTING OFF" "BUILD_STATIC_LIBS ON" -) -CPMAddPackage("gh:curl/curl#curl-8_2_1") -CPMAddPackage( - NAME msgpack-c - GITHUB_REPOSITORY msgpack/msgpack-c - GIT_TAG cpp-6.1.0 - OPTIONS "MSGPACK_CXX20 ON" -) -CPMAddPackage( - NAME nlohmann_json - VERSION 3.11.2 - GITHUB_REPOSITORY nlohmann/json - GITHUB_TAG v3.11.2 - OPTIONS - "JSON_BuildTests OFF" -) find_package(Threads REQUIRED) # Code Sanitizers -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/3rd_party/sanitizers-cmake" ${CMAKE_MODULE_PATH}) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/3rd_party/sanitizers-cmake") find_package(Sanitizers) # Code install(DIRECTORY include/datadog DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) file(GLOB DD_OPENTRACING_SOURCES "src/*.cpp") message(STATUS "Compiler ID: ${CMAKE_CXX_COMPILER_ID}") + +add_library(datadog_project_options INTERFACE) + if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - add_compile_options(-Wall -Wextra -pedantic) + target_compile_options(datadog_project_options INTERFACE -Wall -Wextra -pedantic) if(BUILD_COVERAGE) - add_compile_options(-g -O0 -fprofile-arcs -ftest-coverage) + target_compile_options(datadog_project_options INTERFACE -g -O0 -fprofile-arcs -ftest-coverage) endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - add_compile_options(/W3) + target_compile_options(datadog_project_options INTERFACE /W3) else() message(FATAL_ERROR "Unknown compiler ${CMAKE_CXX_COMPILER_ID}") endif() @@ -86,10 +60,9 @@ endif() if(BUILD_COVERAGE) set(COVERAGE_LIBRARIES gcov) endif() -set(DATADOG_LINK_LIBRARIES opentelemetry_opentracing_shim - +set(DATADOG_LINK_LIBRARIES msgpack-cxx - libcurl Threads::Threads nlohmann_json::nlohmann_json Catch2::Catch2WithMain CLI11::CLI11 ${COVERAGE_LIBRARIES}) + libcurl Threads::Threads nlohmann_json::nlohmann_json Catch2::Catch2WithMain CLI11::CLI11 ${COVERAGE_LIBRARIES} datadog_project_options opentelemetry_api) ## Shared lib if(BUILD_SHARED) @@ -98,8 +71,9 @@ if(BUILD_SHARED) if(BUILD_COVERAGE) target_link_options(dd_opentracing PRIVATE -fprofile-arcs -ftest-coverage) endif() - target_link_libraries(dd_opentracing ${DATADOG_LINK_LIBRARIES}) + target_link_libraries(dd_opentracing opentelemetry_opentracing_shim ${DATADOG_LINK_LIBRARIES}) set_target_properties(dd_opentracing PROPERTIES SOVERSION ${SOVERSION}) + target_include_directories(dd_opentracing PUBLIC include) target_compile_definitions(dd_opentracing PUBLIC DD_OPENTRACING_SHARED) install(TARGETS dd_opentracing LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -110,8 +84,9 @@ endif() if(BUILD_STATIC) add_library(dd_opentracing-static STATIC ${DD_OPENTRACING_SOURCES}) add_sanitizers(dd_opentracing-static) - target_link_libraries(dd_opentracing-static ${DATADOG_LINK_LIBRARIES}) + target_link_libraries(dd_opentracing-static opentelemetry_opentracing_shim_static ${DATADOG_LINK_LIBRARIES}) set_target_properties(dd_opentracing-static PROPERTIES OUTPUT_NAME dd_opentracing POSITION_INDEPENDENT_CODE ON) + target_include_directories(dd_opentracing-static PUBLIC include) target_compile_definitions(dd_opentracing-static PUBLIC DD_OPENTRACING_STATIC) install(TARGETS dd_opentracing-static LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/Dependencies.cmake b/Dependencies.cmake new file mode 100644 index 00000000..e23001b9 --- /dev/null +++ b/Dependencies.cmake @@ -0,0 +1,31 @@ +include(cmake/CPM.cmake) +set(CPM_USE_LOCAL_PACKAGES ON) + +function(add_external_dependencies) + +CPMAddPackage("gh:catchorg/Catch2@3.3.2") +CPMAddPackage("gh:CLIUtils/CLI11@2.3.2") +CPMAddPackage( + NAME opentelemetry-cpp + GITHUB_REPOSITORY maztheman/opentelemetry-cpp + GIT_TAG main + OPTIONS + "WITH_STL ON" "WITH_OPENTRACING ON" "BUILD_TESTING OFF" "BUILD_STATIC_LIBS ON" +) +CPMAddPackage("gh:curl/curl#curl-8_2_1") +CPMAddPackage( + NAME msgpack-c + GITHUB_REPOSITORY msgpack/msgpack-c + GIT_TAG cpp-6.1.0 + OPTIONS "MSGPACK_CXX20 ON" +) +CPMAddPackage( + NAME nlohmann_json + VERSION 3.11.2 + GITHUB_REPOSITORY nlohmann/json + GITHUB_TAG v3.11.2 + OPTIONS + "JSON_BuildTests OFF" +) + +endfunction() \ No newline at end of file From 776173215bc41dfb37c279f7756f4f495dfe4a56 Mon Sep 17 00:00:00 2001 From: Kevin Sucre Date: Mon, 28 Aug 2023 10:38:55 -0600 Subject: [PATCH 04/12] dont use boost? --- Dependencies.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dependencies.cmake b/Dependencies.cmake index e23001b9..aa0b6788 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -17,7 +17,7 @@ CPMAddPackage( NAME msgpack-c GITHUB_REPOSITORY msgpack/msgpack-c GIT_TAG cpp-6.1.0 - OPTIONS "MSGPACK_CXX20 ON" + OPTIONS "MSGPACK_CXX20 ON" "MSGPACK_USE_BOOST OFF" ) CPMAddPackage( NAME nlohmann_json From ebe4885c5798a33f4abe4b2afd30d760c4f0e468 Mon Sep 17 00:00:00 2001 From: maztheman Date: Tue, 29 Aug 2023 06:11:23 -0600 Subject: [PATCH 05/12] Update opentracing.h Revert this change --- include/datadog/opentracing.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/datadog/opentracing.h b/include/datadog/opentracing.h index b1a390bd..b4f6bd81 100644 --- a/include/datadog/opentracing.h +++ b/include/datadog/opentracing.h @@ -16,7 +16,7 @@ #define DD_OPENTRACING_API #endif // _MSC_VER -#include +#include #include #include From 30c9e0aedc2de9d5a2c0fff651eeab69a6c38544 Mon Sep 17 00:00:00 2001 From: maztheman Date: Tue, 29 Aug 2023 06:14:34 -0600 Subject: [PATCH 06/12] Update CMakeLists.txt Revert these changes --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21dd4b86..08a390b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ set(SOVERSION 0) include(GNUInstallDirs) option(BUILD_SHARED "Builds shared library" ON) -option(BUILD_STATIC "Builds static library" ON) +option(BUILD_STATIC "Builds static library" OFF) option(BUILD_OBJECT "Builds objects for use in another project" OFF) option(BUILD_PLUGIN "Builds plugin (requires gcc and not macos)" OFF) option(BUILD_TESTING "Builds tests, also enables BUILD_SHARED" OFF) @@ -26,7 +26,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "RelWithDebInfo") endif() -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 14) include(Dependencies.cmake) add_external_dependencies() From c34ccba06a9d9887185d29182598d74416d82ae8 Mon Sep 17 00:00:00 2001 From: maztheman Date: Tue, 29 Aug 2023 06:21:27 -0600 Subject: [PATCH 07/12] Update Dependencies.cmake Revert to cxx 14 --- Dependencies.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dependencies.cmake b/Dependencies.cmake index aa0b6788..79f80eaa 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -17,7 +17,7 @@ CPMAddPackage( NAME msgpack-c GITHUB_REPOSITORY msgpack/msgpack-c GIT_TAG cpp-6.1.0 - OPTIONS "MSGPACK_CXX20 ON" "MSGPACK_USE_BOOST OFF" + OPTIONS "MSGPACK_CXX14 ON" "MSGPACK_USE_BOOST OFF" ) CPMAddPackage( NAME nlohmann_json @@ -28,4 +28,4 @@ CPMAddPackage( "JSON_BuildTests OFF" ) -endfunction() \ No newline at end of file +endfunction() From 2d25af5897e5c4e3faeb8a1373b55c74cdd352d2 Mon Sep 17 00:00:00 2001 From: Kevin Sucre Date: Tue, 29 Aug 2023 06:38:22 -0600 Subject: [PATCH 08/12] do not use ssl for curl, http only for curl, and STL off (since we reverted cxx20) --- Dependencies.cmake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Dependencies.cmake b/Dependencies.cmake index 79f80eaa..0565337d 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -10,9 +10,16 @@ CPMAddPackage( GITHUB_REPOSITORY maztheman/opentelemetry-cpp GIT_TAG main OPTIONS - "WITH_STL ON" "WITH_OPENTRACING ON" "BUILD_TESTING OFF" "BUILD_STATIC_LIBS ON" + "WITH_STL OFF" "WITH_OPENTRACING ON" "BUILD_TESTING OFF" "BUILD_STATIC_LIBS ON" +) +CPMAddPackage( + NAME curl + GITHUB_REPOSITORY curl/curl + GIT_TAG curl-8_2_1 + OPTIONS + "HTTP_ONLY ON" "CURL_ENABLE_SSL OFF" + ) -CPMAddPackage("gh:curl/curl#curl-8_2_1") CPMAddPackage( NAME msgpack-c GITHUB_REPOSITORY msgpack/msgpack-c From be267326453267aa704e2adefe1d043325d0adf2 Mon Sep 17 00:00:00 2001 From: Kevin Sucre Date: Tue, 29 Aug 2023 06:53:44 -0600 Subject: [PATCH 09/12] Update the include/links --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08a390b3..ef907727 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,7 +97,8 @@ endif() if(BUILD_OBJECT) add_library(dd_opentracing-object OBJECT ${DD_OPENTRACING_SOURCES}) add_sanitizers(dd_opentracing-object) - target_link_libraries(dd_opentracing-object ${CURL_LIBRARIES} Threads::Threads) + target_link_libraries(dd_opentracing-object opentelemetry_opentracing_shim ${DATADOG_LINK_LIBRARIES} ${CURL_LIBRARIES} Threads::Threads) + target_include_directories(dd_opentracing-object PUBLIC include) set_property(TARGET dd_opentracing-object PROPERTY POSITION_INDEPENDENT_CODE ON) target_compile_definitions(dd_opentracing-object PUBLIC DD_OPENTRACING_OBJECT) endif() @@ -114,10 +115,11 @@ if(BUILD_PLUGIN) if(BUILD_COVERAGE) target_link_options(dd_opentracing_plugin PRIVATE -fprofile-arcs -ftest-coverage) endif() - target_link_libraries(dd_opentracing_plugin PUBLIC ${DATADOG_LINK_LIBRARIES} + target_link_libraries(dd_opentracing_plugin PUBLIC opentelemetry_opentracing_shim ${DATADOG_LINK_LIBRARIES} -static-libstdc++ -static-libgcc -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/export.map) + target_include_directories(dd_opentracing_plugin PUBLIC include) install(TARGETS dd_opentracing_plugin LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() From 069b7da77dffb0b9695916f6dcb393c3566a0273 Mon Sep 17 00:00:00 2001 From: Kevin Sucre Date: Tue, 29 Aug 2023 07:55:10 -0600 Subject: [PATCH 10/12] fix pic on curl, use v3 catch2 --- CMakeLists.txt | 2 +- Dependencies.cmake | 4 ++-- scripts/install_dependencies.sh | 2 +- test/CMakeLists.txt | 5 ++--- test/agent_writer_test.cpp | 14 +++++++++----- test/glob_test.cpp | 4 +++- test/limiter_test.cpp | 4 +++- test/logger_test.cpp | 5 ++++- test/opentracing_test.cpp | 4 +++- test/propagation_test.cpp | 4 +++- test/sample_test.cpp | 4 +++- test/span_buffer_test.cpp | 4 +++- test/span_test.cpp | 4 +++- test/tag_propagation_test.cpp | 4 +++- test/test_main.cpp | 2 -- test/tracer_factory_test.cpp | 4 +++- test/tracer_options_test.cpp | 4 +++- test/tracer_test.cpp | 4 +++- 18 files changed, 52 insertions(+), 26 deletions(-) delete mode 100644 test/test_main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ef907727..905b3c04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ if(BUILD_COVERAGE) endif() set(DATADOG_LINK_LIBRARIES msgpack-cxx - libcurl Threads::Threads nlohmann_json::nlohmann_json Catch2::Catch2WithMain CLI11::CLI11 ${COVERAGE_LIBRARIES} datadog_project_options opentelemetry_api) + libcurl Threads::Threads nlohmann_json::nlohmann_json CLI11::CLI11 ${COVERAGE_LIBRARIES} datadog_project_options opentelemetry_api) ## Shared lib if(BUILD_SHARED) diff --git a/Dependencies.cmake b/Dependencies.cmake index 0565337d..17257191 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -17,14 +17,14 @@ CPMAddPackage( GITHUB_REPOSITORY curl/curl GIT_TAG curl-8_2_1 OPTIONS - "HTTP_ONLY ON" "CURL_ENABLE_SSL OFF" + "HTTP_ONLY ON" "CURL_ENABLE_SSL OFF" "BUILD_CURL_EXE OFF" "BUILD_SHARED_LIBS OFF" "CMAKE_POSITION_INDEPENDENT_CODE ON" ) CPMAddPackage( NAME msgpack-c GITHUB_REPOSITORY msgpack/msgpack-c GIT_TAG cpp-6.1.0 - OPTIONS "MSGPACK_CXX14 ON" "MSGPACK_USE_BOOST OFF" + OPTIONS "MSGPACK_CXX14 ON" "MSGPACK_USE_BOOST OFF" "BUILD_SHARED_LIBS OFF" ) CPMAddPackage( NAME nlohmann_json diff --git a/scripts/install_dependencies.sh b/scripts/install_dependencies.sh index 5a36b9fd..7174217e 100755 --- a/scripts/install_dependencies.sh +++ b/scripts/install_dependencies.sh @@ -68,7 +68,7 @@ if [ "$BUILD_MSGPACK" -eq "1" ]; then tar zxf msgpack.tar.gz mkdir -p "msgpack-${MSGPACK_VERSION}/.build" cd "msgpack-${MSGPACK_VERSION}/.build" - cmake -DCMAKE_INSTALL_PREFIX="$install_dir" -DBUILD_SHARED_LIBS=OFF -DMSGPACK_CXX11=ON .. + cmake -DCMAKE_INSTALL_PREFIX="$install_dir" -DBUILD_SHARED_LIBS=OFF -DMSGPACK_CXX14=ON .. make --jobs="$MAKE_JOB_COUNT" make install cd ../.. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 67d0e22b..0c7728d1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,3 @@ -add_library(catch STATIC test_main.cpp) - macro(_datadog_test TEST_NAME) add_executable(${TEST_NAME} ${ARGN}) add_sanitizers(${TEST_NAME}) @@ -7,8 +5,9 @@ macro(_datadog_test TEST_NAME) target_link_options(${TEST_NAME} PRIVATE -fprofile-arcs -ftest-coverage) endif() target_link_libraries(${TEST_NAME} dd_opentracing + Catch2::Catch2WithMain ${DATADOG_LINK_LIBRARIES} - catch) + ) add_test(${TEST_NAME} ${TEST_NAME}) endmacro() diff --git a/test/agent_writer_test.cpp b/test/agent_writer_test.cpp index 6baa6261..96e25dc5 100644 --- a/test/agent_writer_test.cpp +++ b/test/agent_writer_test.cpp @@ -1,8 +1,10 @@ #include "../src/agent_writer.h" +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING #include -#include +#include #include #include "mocks.h" @@ -185,7 +187,7 @@ TEST_CASE("writer") { } SECTION("handle error responses") { - using Catch::Matchers::Contains; + using Catch::Matchers::ContainsSubstring; // HTTP status zero indicates "no status." handle->response_status = 0; @@ -195,7 +197,8 @@ TEST_CASE("writer") { writer.flush(std::chrono::seconds(10)); REQUIRE(logger->records.size() != 0); // The logged error diagnostic will say that there was no response status. - REQUIRE_THAT(logger->records.back().message, Contains("response without an HTTP status")); + REQUIRE_THAT(logger->records.back().message, + ContainsSubstring("response without an HTTP status")); // HTTP status 200 with an empty body means that the response really should // be 429 "too many requests," but the Agent is not configured to return @@ -207,7 +210,7 @@ TEST_CASE("writer") { writer.flush(std::chrono::seconds(10)); REQUIRE(logger->records.size() != 0); // The logged error diagnostic will mention the lack of response. - REQUIRE_THAT(logger->records.back().message, Contains("response without a body")); + REQUIRE_THAT(logger->records.back().message, ContainsSubstring("response without a body")); // HTTP statuses other than 200 are unexpected. std::vector statuses; @@ -225,7 +228,8 @@ TEST_CASE("writer") { writer.flush(std::chrono::seconds(10)); REQUIRE(logger->records.size() != 0); // The logged error diagnostic will contain the response status. - REQUIRE_THAT(logger->records.back().message, Contains(" " + std::to_string(status) + " ")); + REQUIRE_THAT(logger->records.back().message, + ContainsSubstring(" " + std::to_string(status) + " ")); } SECTION("queue does not grow indefinitely") { diff --git a/test/glob_test.cpp b/test/glob_test.cpp index 973a9322..18774114 100644 --- a/test/glob_test.cpp +++ b/test/glob_test.cpp @@ -3,7 +3,9 @@ #include "../src/glob.h" -#include +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING +#include using namespace datadog::opentracing; diff --git a/test/limiter_test.cpp b/test/limiter_test.cpp index 837e2404..7afb77d9 100644 --- a/test/limiter_test.cpp +++ b/test/limiter_test.cpp @@ -1,6 +1,8 @@ #include "../src/limiter.h" -#include +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING +#include #include "mocks.h" using namespace datadog::opentracing; diff --git a/test/logger_test.cpp b/test/logger_test.cpp index b22f96b5..699bf21c 100644 --- a/test/logger_test.cpp +++ b/test/logger_test.cpp @@ -1,6 +1,9 @@ #include "../src/logger.h" -#include +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING +#include + using namespace datadog::opentracing; TEST_CASE("logger") { diff --git a/test/opentracing_test.cpp b/test/opentracing_test.cpp index a956ced2..c40827aa 100644 --- a/test/opentracing_test.cpp +++ b/test/opentracing_test.cpp @@ -1,6 +1,8 @@ #include -#include +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING +#include #include "mocks.h" using namespace datadog::opentracing; diff --git a/test/propagation_test.cpp b/test/propagation_test.cpp index d9a542d2..0a685527 100644 --- a/test/propagation_test.cpp +++ b/test/propagation_test.cpp @@ -1,9 +1,11 @@ +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING #include #include #include #include -#include +#include #include #include diff --git a/test/sample_test.cpp b/test/sample_test.cpp index 53c93c03..b323c148 100644 --- a/test/sample_test.cpp +++ b/test/sample_test.cpp @@ -1,7 +1,9 @@ #include "../src/sample.h" +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING #include -#include +#include #include #include diff --git a/test/span_buffer_test.cpp b/test/span_buffer_test.cpp index 18a63138..d2b56af4 100644 --- a/test/span_buffer_test.cpp +++ b/test/span_buffer_test.cpp @@ -1,6 +1,8 @@ #include "../src/span_buffer.h" -#include +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING +#include #include "../src/sample.h" #include "mocks.h" diff --git a/test/span_test.cpp b/test/span_test.cpp index 843e11ba..1f147da1 100644 --- a/test/span_test.cpp +++ b/test/span_test.cpp @@ -1,9 +1,11 @@ #include "../src/span.h" +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING #include #include -#include +#include #include #include #include diff --git a/test/tag_propagation_test.cpp b/test/tag_propagation_test.cpp index 5ab2027c..694345c2 100644 --- a/test/tag_propagation_test.cpp +++ b/test/tag_propagation_test.cpp @@ -3,8 +3,10 @@ #include "../src/tag_propagation.h" +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING #include -#include +#include #include #include #include diff --git a/test/test_main.cpp b/test/test_main.cpp deleted file mode 100644 index 4ed06df1..00000000 --- a/test/test_main.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN -#include diff --git a/test/tracer_factory_test.cpp b/test/tracer_factory_test.cpp index 9ebddc8a..b15595ac 100644 --- a/test/tracer_factory_test.cpp +++ b/test/tracer_factory_test.cpp @@ -1,8 +1,10 @@ #include "../src/tracer_factory.h" +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING #include -#include +#include #include #include #include diff --git a/test/tracer_options_test.cpp b/test/tracer_options_test.cpp index dbe772a9..6be92422 100644 --- a/test/tracer_options_test.cpp +++ b/test/tracer_options_test.cpp @@ -1,8 +1,10 @@ #include "../src/tracer_options.h" +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING #include -#include +#include #include using namespace datadog::opentracing; using namespace std::string_literals; diff --git a/test/tracer_test.cpp b/test/tracer_test.cpp index 08669f6e..f2565ab7 100644 --- a/test/tracer_test.cpp +++ b/test/tracer_test.cpp @@ -1,9 +1,11 @@ #include "../src/tracer.h" +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING #include #include -#include +#include #include #include "../src/sample.h" From 3e772823f88141018b254ce6fc04c82b1c2e28ac Mon Sep 17 00:00:00 2001 From: Kevin Sucre Date: Tue, 29 Aug 2023 08:10:10 -0600 Subject: [PATCH 11/12] probably didnt need 3.14 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 905b3c04..e8449f65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.13) project(dd-opentracing-cpp CXX C) From c1f23390809a569f85acb2cc53c104d375f23556 Mon Sep 17 00:00:00 2001 From: maztheman Date: Tue, 5 Sep 2023 15:14:37 -0600 Subject: [PATCH 12/12] Update Dependencies.cmake --- Dependencies.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dependencies.cmake b/Dependencies.cmake index 17257191..296c22b3 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -10,7 +10,7 @@ CPMAddPackage( GITHUB_REPOSITORY maztheman/opentelemetry-cpp GIT_TAG main OPTIONS - "WITH_STL OFF" "WITH_OPENTRACING ON" "BUILD_TESTING OFF" "BUILD_STATIC_LIBS ON" + "WITH_STL OFF" "WITH_OPENTRACING ON" "BUILD_TESTING OFF" "BUILD_STATIC_LIBS ON" "WITH_EXAMPLES OFF" ) CPMAddPackage( NAME curl