From 6344d37ec9294f7a25e448f0a6f4c20d4e789b61 Mon Sep 17 00:00:00 2001 From: owent Date: Wed, 5 May 2021 14:09:28 +0800 Subject: [PATCH] Fix #724 Signed-off-by: owent --- exporters/elasticsearch/CMakeLists.txt | 3 +++ exporters/otlp/CMakeLists.txt | 14 +++++--------- exporters/zipkin/CMakeLists.txt | 6 ++++-- ext/src/http/client/curl/CMakeLists.txt | 13 ++++++++++++- opentelemetry-cpp-config.cmake.in | 1 + sdk/src/common/core.cc | 13 +++++++++++++ 6 files changed, 38 insertions(+), 12 deletions(-) diff --git a/exporters/elasticsearch/CMakeLists.txt b/exporters/elasticsearch/CMakeLists.txt index 0c303db074..1bd671696b 100644 --- a/exporters/elasticsearch/CMakeLists.txt +++ b/exporters/elasticsearch/CMakeLists.txt @@ -3,6 +3,9 @@ include_directories(${CMAKE_SOURCE_DIR}/ext/include) add_library(opentelemetry_exporter_elasticsearch_logs src/es_log_exporter.cc) +target_link_libraries(opentelemetry_exporter_elasticsearch_logs + PUBLIC opentelemetry_trace http_client_curl) + if(BUILD_TESTING) add_executable(es_log_exporter_test test/es_log_exporter_test.cc) diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index 526a824da6..c2acd6b0ca 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -6,7 +6,8 @@ set_target_properties(opentelemetry_exporter_otprotocol target_link_libraries( opentelemetry_exporter_otprotocol - PUBLIC opentelemetry_trace opentelemetry_resources opentelemetry_proto) + PUBLIC opentelemetry_trace opentelemetry_resources opentelemetry_proto + protobuf::libprotobuf gRPC::grpc++) install( TARGETS opentelemetry_exporter_otprotocol @@ -29,7 +30,7 @@ if(BUILD_TESTING) add_executable(recordable_test test/recordable_test.cc) target_link_libraries( recordable_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} - opentelemetry_exporter_otprotocol protobuf::libprotobuf gRPC::grpc++) + opentelemetry_exporter_otprotocol) gtest_add_tests( TARGET recordable_test TEST_PREFIX exporter.otlp. @@ -44,13 +45,8 @@ if(BUILD_TESTING) endif() add_executable(otlp_exporter_test test/otlp_exporter_test.cc) target_link_libraries( - otlp_exporter_test - ${GTEST_BOTH_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} - ${GMOCK_LIB} - opentelemetry_exporter_otprotocol - protobuf::libprotobuf - gRPC::grpc++) + otlp_exporter_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} + ${GMOCK_LIB} opentelemetry_exporter_otprotocol) gtest_add_tests( TARGET otlp_exporter_test TEST_PREFIX exporter.otlp. diff --git a/exporters/zipkin/CMakeLists.txt b/exporters/zipkin/CMakeLists.txt index 50c3103533..5f6f9887a6 100644 --- a/exporters/zipkin/CMakeLists.txt +++ b/exporters/zipkin/CMakeLists.txt @@ -20,6 +20,9 @@ endif() add_library(opentelemetry_exporter_zipkin_trace src/zipkin_exporter.cc src/recordable.cc) +target_link_libraries(opentelemetry_exporter_zipkin_trace + PUBLIC opentelemetry_trace http_client_curl) + install( TARGETS opentelemetry_exporter_zipkin_trace EXPORT "${PROJECT_NAME}-target" @@ -38,8 +41,7 @@ if(BUILD_TESTING) target_link_libraries( zipkin_recordable_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} - opentelemetry_exporter_zipkin_trace opentelemetry_resources - http_client_curl) + opentelemetry_exporter_zipkin_trace opentelemetry_resources) gtest_add_tests( TARGET zipkin_recordable_test diff --git a/ext/src/http/client/curl/CMakeLists.txt b/ext/src/http/client/curl/CMakeLists.txt index 0b85847b0d..b2265e5d2a 100644 --- a/ext/src/http/client/curl/CMakeLists.txt +++ b/ext/src/http/client/curl/CMakeLists.txt @@ -1,5 +1,16 @@ find_package(CURL) if(CURL_FOUND) add_library(http_client_curl http_client_factory_curl http_client_curl) - target_link_libraries(http_client_curl CURL::libcurl) + + set_target_properties(http_client_curl PROPERTIES EXPORT_NAME + http_client_curl) + + target_link_libraries(http_client_curl PUBLIC CURL::libcurl) + + install( + TARGETS http_client_curl + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() diff --git a/opentelemetry-cpp-config.cmake.in b/opentelemetry-cpp-config.cmake.in index 589d4acabc..bd289b888f 100644 --- a/opentelemetry-cpp-config.cmake.in +++ b/opentelemetry-cpp-config.cmake.in @@ -35,6 +35,7 @@ # opentelemetry-cpp::ostream_span_exporter - Imported target of opentelemetry-cpp::ostream_span_exporter # opentelemetry-cpp::prometheus_exporter - Imported target of opentelemetry-cpp::prometheus_exporter # opentelemetry-cpp::zpages - Imported target of opentelemetry-cpp::zpages +# opentelemetry-cpp::http_client_curl - Imported target of opentelemetry-cpp::http_client_curl # # ============================================================================= diff --git a/sdk/src/common/core.cc b/sdk/src/common/core.cc index a8db9a0448..aaf013e2c6 100644 --- a/sdk/src/common/core.cc +++ b/sdk/src/common/core.cc @@ -2,6 +2,19 @@ #include "opentelemetry/version.h" #if defined(HAVE_ABSEIL) + +# if defined(__GNUC__) || defined(__GNUG__) +# ifndef __cdecl +// see https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html +// Intel x86 architecture specific calling conventions +# ifdef _M_IX86 +# define __cdecl __attribute__((__cdecl__)) +# else +# define __cdecl +# endif +# endif +# endif + namespace absl { namespace variant_internal