diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c9ab0b816..dad2471128 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,27 @@ cmake_policy(SET CMP0057 NEW) project(opentelemetry-cpp) +file(READ "${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h" + OPENTELEMETRY_CPP_HEADER_VERSION_H) +if(OPENTELEMETRY_CPP_HEADER_VERSION_H MATCHES + "OPENTELEMETRY_ABI_VERSION_NO[ \t\r\n]+\"?([0-9]+)\"?") + math(EXPR OPENTELEMETRY_ABI_VERSION_NO ${CMAKE_MATCH_1}) +else() + message( + FATAL_ERROR + "OPENTELEMETRY_ABI_VERSION_NO not found on ${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h" + ) +endif() +if(OPENTELEMETRY_CPP_HEADER_VERSION_H MATCHES + "OPENTELEMETRY_VERSION[ \t\r\n]+\"?([^\"]+)\"?") + set(OPENTELEMETRY_VERSION ${CMAKE_MATCH_1}) +else() + message( + FATAL_ERROR + "OPENTELEMETRY_VERSION not found on ${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h" + ) +endif() + if(NOT DEFINED CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) endif() @@ -81,6 +102,13 @@ if(MSVC) # for recent C++ language standards. Without this option MSVC returns the # value of __cplusplus="199711L" set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") + + # When using vcpkg, all targets build with the same runtime + if(VCPKG_TOOLCHAIN) + set(CMAKE_MSVC_RUNTIME_LIBRARY + "MultiThreaded$<$:Debug>$<$:DLL>" + CACHE STRING "") + endif() endif() if(WITH_OTLP) @@ -156,6 +184,9 @@ if(BUILD_TESTING) find_package(benchmark CONFIG REQUIRED) endif() +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + include_directories(api/include) add_subdirectory(api) include_directories(sdk/include) @@ -167,3 +198,34 @@ if(WITH_EXAMPLES) add_subdirectory(examples) endif() add_subdirectory(ext) + +# Export cmake config and support find_packages(opentelemetry-cpp CONFIG) Write +# config file for find_packages(opentelemetry-cpp CONFIG) +configure_package_config_file( + "${CMAKE_CURRENT_LIST_DIR}/opentelemetry-cpp-config.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake" + PATH_VARS OPENTELEMETRY_ABI_VERSION_NO OPENTELEMETRY_VERSION PROJECT_NAME + CMAKE_INSTALL_LIBDIR + NO_CHECK_REQUIRED_COMPONENTS_MACRO) + +# Write version file for find_packages(opentelemetry-cpp CONFIG) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-config-version.cmake" + VERSION ${OPENTELEMETRY_VERSION} + COMPATIBILITY ExactVersion) + +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-config-version.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake") + +# Export all components +export( + EXPORT "${PROJECT_NAME}-target" + NAMESPACE "${PROJECT_NAME}::" + FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-target.cmake") +install( + EXPORT "${PROJECT_NAME}-target" + NAMESPACE "${PROJECT_NAME}::" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake") diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 2f6eed51fb..d9822530a2 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -1,7 +1,17 @@ add_library(opentelemetry_api INTERFACE) target_include_directories( - opentelemetry_api INTERFACE include - $) + opentelemetry_api + INTERFACE "$" + "$") + +set_target_properties(opentelemetry_api PROPERTIES EXPORT_NAME api) + +install( + TARGETS opentelemetry_api + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install( DIRECTORY include/opentelemetry diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index 3821d4178e..50e1c2f7df 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -132,6 +132,24 @@ add_library( ${METRICS_SERVICE_PB_CPP_FILE} ${METRICS_SERVICE_GRPC_PB_CPP_FILE}) +set_target_properties(opentelemetry_proto PROPERTIES EXPORT_NAME proto) + +install( + TARGETS opentelemetry_proto + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +if(TARGET protobuf::libprotobuf) + target_link_libraries(opentelemetry_proto PUBLIC protobuf::libprotobuf) +else() # cmake 3.8 or lower + target_include_directories(opentelemetry_proto + PUBLIC ${Protobuf_INCLUDE_DIRS}) + target_include_directories(opentelemetry_proto + INTERFACE ${Protobuf_LIBRARIES}) +endif() + if(BUILD_SHARED_LIBS) set_property(TARGET opentelemetry_proto PROPERTY POSITION_INDEPENDENT_CODE ON) endif() diff --git a/exporters/memory/CMakeLists.txt b/exporters/memory/CMakeLists.txt index 2739596fd5..870e932730 100644 --- a/exporters/memory/CMakeLists.txt +++ b/exporters/memory/CMakeLists.txt @@ -2,7 +2,26 @@ include_directories(include) add_library(opentelemetry_exporter_in_memory INTERFACE) -target_include_directories(opentelemetry_exporter_in_memory INTERFACE include/) +target_include_directories( + opentelemetry_exporter_in_memory + INTERFACE "$" + "$") + +set_target_properties(opentelemetry_exporter_in_memory + PROPERTIES EXPORT_NAME in_memory_span_exporter) + +install( + TARGETS opentelemetry_exporter_in_memory + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install( + DIRECTORY include/opentelemetry/exporters/memory + DESTINATION include/opentelemetry/exporters/ + FILES_MATCHING + PATTERN "*.h") if(BUILD_TESTING) add_executable(in_memory_span_data_test test/in_memory_span_data_test.cc) diff --git a/exporters/ostream/CMakeLists.txt b/exporters/ostream/CMakeLists.txt index 909ce7fdbe..b9797b2974 100644 --- a/exporters/ostream/CMakeLists.txt +++ b/exporters/ostream/CMakeLists.txt @@ -1,25 +1,65 @@ -include_directories(include) - add_library(opentelemetry_exporter_ostream_logs src/log_exporter.cc) add_library(opentelemetry_exporter_ostream_metrics src/metrics_exporter.cc) add_library(opentelemetry_exporter_ostream_span src/span_exporter.cc) +set_target_properties(opentelemetry_exporter_ostream_logs + PROPERTIES EXPORT_NAME ostream_log_exporter) + +set_target_properties(opentelemetry_exporter_ostream_metrics + PROPERTIES EXPORT_NAME ostream_metrics_exporter) + +set_target_properties(opentelemetry_exporter_ostream_span + PROPERTIES EXPORT_NAME ostream_span_exporter) + +target_include_directories( + opentelemetry_exporter_ostream_logs + PUBLIC "$") + +target_include_directories( + opentelemetry_exporter_ostream_metrics + PUBLIC "$") + +target_include_directories( + opentelemetry_exporter_ostream_span + PUBLIC "$") + +target_link_libraries(opentelemetry_exporter_ostream_logs + PUBLIC opentelemetry_logs) + +target_link_libraries(opentelemetry_exporter_ostream_metrics + PUBLIC opentelemetry_metrics) + +target_link_libraries(opentelemetry_exporter_ostream_span + PUBLIC opentelemetry_trace) + +install( + TARGETS opentelemetry_exporter_ostream_logs + opentelemetry_exporter_ostream_metrics + opentelemetry_exporter_ostream_span + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install( + DIRECTORY include/opentelemetry/exporters/ostream + DESTINATION include/opentelemetry/exporters/ + FILES_MATCHING + PATTERN "*.h") + if(BUILD_TESTING) add_executable(ostream_metrics_test test/ostream_metrics_test.cc) add_executable(ostream_span_test test/ostream_span_test.cc) add_executable(ostream_log_test test/ostream_log_test.cc) - target_link_libraries( - ostream_span_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} - ${CORE_RUNTIME_LIBS} opentelemetry_exporter_ostream_span) + target_link_libraries(ostream_span_test ${GTEST_BOTH_LIBRARIES} + opentelemetry_exporter_ostream_span) - target_link_libraries( - ostream_metrics_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} - ${CORE_RUNTIME_LIBS} opentelemetry_exporter_ostream_metrics) + target_link_libraries(ostream_metrics_test ${GTEST_BOTH_LIBRARIES} + opentelemetry_exporter_ostream_metrics) - target_link_libraries( - ostream_log_test ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} - opentelemetry_exporter_ostream_logs opentelemetry_logs) + target_link_libraries(ostream_log_test ${GTEST_BOTH_LIBRARIES} + opentelemetry_exporter_ostream_logs) gtest_add_tests( TARGET ostream_log_test diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index df54178c61..e4b2999f6d 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -1,8 +1,28 @@ -include_directories(include) - add_library(opentelemetry_exporter_otprotocol src/recordable.cc src/otlp_exporter.cc) -target_link_libraries(opentelemetry_exporter_otprotocol opentelemetry_proto) + +set_target_properties(opentelemetry_exporter_otprotocol + PROPERTIES EXPORT_NAME otlp_exporter) + +target_link_libraries(opentelemetry_exporter_otprotocol + PUBLIC opentelemetry_trace opentelemetry_proto) + +install( + TARGETS opentelemetry_exporter_otprotocol + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install( + DIRECTORY include/opentelemetry/exporters/otlp + DESTINATION include/opentelemetry/exporters/ + FILES_MATCHING + PATTERN "*.h") + +target_include_directories( + opentelemetry_exporter_otprotocol + PUBLIC "$") if(BUILD_TESTING) add_executable(recordable_test test/recordable_test.cc) diff --git a/exporters/prometheus/CMakeLists.txt b/exporters/prometheus/CMakeLists.txt index 1a58b175fb..d6b8eefea5 100644 --- a/exporters/prometheus/CMakeLists.txt +++ b/exporters/prometheus/CMakeLists.txt @@ -12,13 +12,32 @@ # See the License for the specific language governing permissions and # limitations under the License. -include_directories(include) - find_package(prometheus-cpp CONFIG REQUIRED) add_library(prometheus_exporter src/prometheus_collector.cc src/prometheus_exporter_utils.cc) +target_include_directories( + prometheus_exporter + PUBLIC "$" + "$") + +target_link_libraries(prometheus_exporter PUBLIC opentelemetry_metrics + prometheus-cpp::core) + +install( + TARGETS prometheus_exporter + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install( + DIRECTORY include/opentelemetry/exporters/prometheus + DESTINATION include/opentelemetry/exporters/ + FILES_MATCHING + PATTERN "*.h") + if(BUILD_TESTING) add_subdirectory(test) endif() diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index fa8f1e9498..17a765a92b 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -1,3 +1,24 @@ +add_library(opentelemetry_ext INTERFACE) +target_include_directories( + opentelemetry_ext + INTERFACE "$" + "$") + +set_target_properties(opentelemetry_ext PROPERTIES EXPORT_NAME "ext") + +install( + TARGETS opentelemetry_ext + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install( + DIRECTORY include/opentelemetry/ext + DESTINATION include/opentelemetry/ + FILES_MATCHING + PATTERN "*.h") + add_subdirectory(src) include_directories(include) diff --git a/ext/src/zpages/CMakeLists.txt b/ext/src/zpages/CMakeLists.txt index dae0249bf4..5440ea3fa6 100644 --- a/ext/src/zpages/CMakeLists.txt +++ b/ext/src/zpages/CMakeLists.txt @@ -6,7 +6,15 @@ add_library( ../../include/opentelemetry/ext/zpages/tracez_data_aggregator.h ../../include/opentelemetry/ext/zpages/tracez_http_server.h) -target_include_directories(opentelemetry_zpages PUBLIC ../../include) +set_target_properties(opentelemetry_zpages PROPERTIES EXPORT_NAME zpages) -target_link_libraries(opentelemetry_zpages opentelemetry_api - opentelemetry_trace) +target_link_libraries( + opentelemetry_zpages PUBLIC opentelemetry_ext opentelemetry_api + opentelemetry_trace) + +install( + TARGETS opentelemetry_zpages + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/ext/test/http/CMakeLists.txt b/ext/test/http/CMakeLists.txt index a32c012492..f063c887d1 100644 --- a/ext/test/http/CMakeLists.txt +++ b/ext/test/http/CMakeLists.txt @@ -3,9 +3,15 @@ if(CURL_FOUND) set(CURL_LIBRARY "-lcurl") set(FILENAME curl_http_test) add_executable(${FILENAME} ${FILENAME}.cc) - include_directories(${CURL_INCLUDE_DIR}) target_link_libraries(${FILENAME} ${GTEST_BOTH_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} ${CURL_LIBRARIES}) + ${CMAKE_THREAD_LIBS_INIT}) + + if(TARGET CURL::libcurl) + target_link_libraries(${FILENAME} CURL::libcurl) + else() + include_directories(${CURL_INCLUDE_DIRS}) + target_link_libraries(${FILENAME} ${CURL_LIBRARIES}) + endif() gtest_add_tests( TARGET ${FILENAME} TEST_PREFIX ext.http.curl. diff --git a/opentelemetry-cpp-config.cmake.in b/opentelemetry-cpp-config.cmake.in new file mode 100644 index 0000000000..2600cd21f3 --- /dev/null +++ b/opentelemetry-cpp-config.cmake.in @@ -0,0 +1,90 @@ +#.rst: +# opentelemetry-cpp-config.cmake +# -------- +# +# Find the native opentelemetry-cpp includes and library. +# +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following variables: +# +# :: +# +# OPENTELEMETRY_CPP_INCLUDE_DIRS - Include directories of opentelemetry-cpp. +# OPENTELEMETRY_CPP_LIBRARY_DIRS - Link directories of opentelemetry-cpp. +# OPENTELEMETRY_CPP_LIBRARIES - List of libraries when using opentelemetry-cpp. +# OPENTELEMETRY_CPP_FOUND - True if opentelemetry-cpp found. +# OPENTELEMETRY_ABI_VERSION_NO - ABI version of opentelemetry-cpp. +# OPENTELEMETRY_VERSION - Version of opentelemetry-cpp. +# +# :: +# opentelemetry-cpp::api - Imported target of opentelemetry-cpp::api +# opentelemetry-cpp::sdk - Imported target of opentelemetry-cpp::sdk +# opentelemetry-cpp::ext - Imported target of opentelemetry-cpp::ext +# opentelemetry-cpp::version - Imported target of opentelemetry-cpp::version +# opentelemetry-cpp::common - Imported target of opentelemetry-cpp::common +# opentelemetry-cpp::trace - Imported target of opentelemetry-cpp::trace +# opentelemetry-cpp::metrics - Imported target of opentelemetry-cpp::metrics +# opentelemetry-cpp::logs - Imported target of opentelemetry-cpp::logs +# opentelemetry-cpp::in_memory_span_exporter - Imported target of opentelemetry-cpp::in_memory_span_exporter +# opentelemetry-cpp::otlp_exporter - Imported target of opentelemetry-cpp::otlp_exporter +# opentelemetry-cpp::ostream_log_exporter - Imported target of opentelemetry-cpp::ostream_log_exporter +# opentelemetry-cpp::ostream_metrics_exporter - Imported target of opentelemetry-cpp::ostream_metrics_exporter +# 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 +# + +# ============================================================================= +# Copyright 2020 opentelemetry. +# +# Distributed under the Apache License (the "License"); see accompanying file +# LICENSE for details. +# ============================================================================= + +set(OPENTELEMETRY_ABI_VERSION_NO + "@OPENTELEMETRY_ABI_VERSION_NO@" + CACHE STRING "opentelemetry-cpp ABI version" FORCE) +set(OPENTELEMETRY_VERSION + "@OPENTELEMETRY_VERSION@" + CACHE STRING "opentelemetry-cpp version" FORCE) + +@PACKAGE_INIT@ + +# ############################################################################## + +set_and_check(OPENTELEMETRY_CPP_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@") +set_and_check(OPENTELEMETRY_CPP_LIBRARY_DIRS "@PACKAGE_CMAKE_INSTALL_LIBDIR@") + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-target.cmake") + +set(OPENTELEMETRY_CPP_LIBRARIES) +set(_OPENTELEMETRY_CPP_LIBRARIES_TEST_TARGETS + api + sdk + ext + version + common + trace + metrics + logs + otlp_exporter + ostream_log_exporter + ostream_metrics_exporter + ostream_span_exporter + zpages) +foreach(_TEST_TARGET IN LISTS _OPENTELEMETRY_CPP_LIBRARIES_TEST_TARGETS) + if(TARGET opentelemetry-cpp::${_TEST_TARGET}) + list(APPEND OPENTELEMETRY_CPP_LIBRARIES opentelemetry-cpp::${_TEST_TARGET}) + endif() +endforeach() + +# handle the QUIETLY and REQUIRED arguments and set OPENTELEMETRY_CPP_FOUND to +# TRUE if all listed variables are TRUE +include("FindPackageHandleStandardArgs") +find_package_handle_standard_args( + OPENTELEMETRY_CPP + FOUND_VAR OPENTELEMETRY_CPP_FOUND + REQUIRED_VARS OPENTELEMETRY_CPP_INCLUDE_DIRS OPENTELEMETRY_CPP_LIBRARIES) diff --git a/sdk/CMakeLists.txt b/sdk/CMakeLists.txt index 75205ac71e..a54e2ecc7b 100644 --- a/sdk/CMakeLists.txt +++ b/sdk/CMakeLists.txt @@ -1,3 +1,24 @@ +add_library(opentelemetry_sdk INTERFACE) +target_include_directories( + opentelemetry_sdk + INTERFACE "$" + "$") + +set_target_properties(opentelemetry_sdk PROPERTIES EXPORT_NAME sdk) + +install( + TARGETS opentelemetry_sdk + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install( + DIRECTORY include/opentelemetry/sdk + DESTINATION include/opentelemetry/ + FILES_MATCHING + PATTERN "*.h") + add_subdirectory(src) if(BUILD_TESTING) diff --git a/sdk/src/common/CMakeLists.txt b/sdk/src/common/CMakeLists.txt index 4a47500a73..22a7e0aca4 100644 --- a/sdk/src/common/CMakeLists.txt +++ b/sdk/src/common/CMakeLists.txt @@ -6,5 +6,16 @@ else() endif() add_library(opentelemetry_common ${COMMON_SRCS}) -target_link_libraries(opentelemetry_common Threads::Threads - ${CORE_RUNTIME_LIBS}) + +set_target_properties(opentelemetry_common PROPERTIES EXPORT_NAME common) + +target_link_libraries( + opentelemetry_common PUBLIC opentelemetry_api opentelemetry_sdk + Threads::Threads ${CORE_RUNTIME_LIBS}) + +install( + TARGETS opentelemetry_common + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/sdk/src/logs/CMakeLists.txt b/sdk/src/logs/CMakeLists.txt index 44d8909472..70eccf2f15 100644 --- a/sdk/src/logs/CMakeLists.txt +++ b/sdk/src/logs/CMakeLists.txt @@ -1,4 +1,17 @@ add_library(opentelemetry_logs logger_provider.cc logger.cc simple_log_processor.cc batch_log_processor.cc) +set_target_properties(opentelemetry_logs PROPERTIES EXPORT_NAME logs) + target_link_libraries(opentelemetry_logs opentelemetry_common) + +target_include_directories( + opentelemetry_logs + PUBLIC "$") + +install( + TARGETS opentelemetry_logs + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/sdk/src/metrics/CMakeLists.txt b/sdk/src/metrics/CMakeLists.txt index c147a3e3c2..7ff562b588 100644 --- a/sdk/src/metrics/CMakeLists.txt +++ b/sdk/src/metrics/CMakeLists.txt @@ -1,2 +1,17 @@ add_library(opentelemetry_metrics meter_provider.cc meter.cc ungrouped_processor.cc) + +set_target_properties(opentelemetry_metrics PROPERTIES EXPORT_NAME metrics) + +target_link_libraries(opentelemetry_metrics PUBLIC opentelemetry_common) + +target_include_directories( + opentelemetry_metrics + PUBLIC "$") + +install( + TARGETS opentelemetry_metrics + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/sdk/src/trace/CMakeLists.txt b/sdk/src/trace/CMakeLists.txt index 97f4f3d3b3..2ae5ef7bb6 100644 --- a/sdk/src/trace/CMakeLists.txt +++ b/sdk/src/trace/CMakeLists.txt @@ -3,5 +3,17 @@ add_library( tracer_provider.cc tracer.cc span.cc batch_span_processor.cc samplers/parent.cc samplers/trace_id_ratio.cc) -target_link_libraries(opentelemetry_trace opentelemetry_common - ${CORE_RUNTIME_LIBS}) +set_target_properties(opentelemetry_trace PROPERTIES EXPORT_NAME trace) + +target_link_libraries(opentelemetry_trace PUBLIC opentelemetry_common) + +target_include_directories( + opentelemetry_trace + PUBLIC "$") + +install( + TARGETS opentelemetry_trace + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/sdk/src/version/CMakeLists.txt b/sdk/src/version/CMakeLists.txt index 820928752c..59231070b9 100644 --- a/sdk/src/version/CMakeLists.txt +++ b/sdk/src/version/CMakeLists.txt @@ -1 +1,17 @@ add_library(opentelemetry_version version.cc) + +set_target_properties(opentelemetry_version PROPERTIES EXPORT_NAME version) + +target_link_libraries(opentelemetry_version PUBLIC opentelemetry_api + opentelemetry_sdk) + +target_include_directories( + opentelemetry_version + PUBLIC "$") + +install( + TARGETS opentelemetry_version + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/tools/format.sh b/tools/format.sh index 523cceb75d..c7db8de540 100755 --- a/tools/format.sh +++ b/tools/format.sh @@ -36,7 +36,7 @@ $CLANG_FORMAT -i -style=file \ if which cmake-format >/dev/null; then echo "Running cmake-format $(cmake-format --version 2>&1)." - cmake-format -i $($FIND -name 'CMakeLists.txt' -print) + cmake-format -i $($FIND -name 'CMakeLists.txt' -print -name '*.cmake' -print -name '*.cmake.in' -print) else echo "Can't find cmake-format. It can be installed with:" echo " pip install --user cmake_format"