diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1576ad4e37..a120f4ff27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -264,6 +264,22 @@ jobs: sudo ./ci/setup_grpc.sh ./ci/do_ci.sh cmake.exporter.otprotocol.test + cmake_do_not_install_test: + name: CMake do not install test (with otlp-exporter) + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + - name: setup + run: | + sudo ./ci/setup_cmake.sh + sudo ./ci/setup_ci_environment.sh + - name: run otlp exporter tests + run: | + sudo ./ci/setup_grpc.sh + ./ci/do_ci.sh cmake.do_not_install.test + plugin_test: name: Plugin -> CMake runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e85d23935..31bfde54a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ Increment the: ## [Unreleased] +* [BUILD] Add `OPENTELEMETRY_INSTALL` to allow user to skip install targets. + [#2022](https://github.com/open-telemetry/opentelemetry-cpp/pull/2022) * [SDK] Rename the global SDK version variables to avoid naming clash [#2011](https://github.com/open-telemetry/opentelemetry-cpp/pull/2011) * [SDK]Add attributes for InstrumentationScope diff --git a/CMakeLists.txt b/CMakeLists.txt index 72b71201ac..f4fa0649ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,14 @@ option(WITH_GSL option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF) +if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(OPENTELEMETRY_INSTALL_default ON) +else() + set(OPENTELEMETRY_INSTALL_default OFF) +endif() +option(OPENTELEMETRY_INSTALL "Whether to install opentelemetry targets" + ${OPENTELEMETRY_INSTALL_default}) + if(NOT DEFINED CMAKE_CXX_STANDARD) if(WITH_STL) # Require at least C++17. C++20 is needed to avoid gsl::span @@ -579,41 +587,43 @@ if(NOT WITH_API_ONLY) endif() endif() -# Export cmake config and support find_packages(opentelemetry-cpp CONFIG) Write -# config file for find_packages(opentelemetry-cpp CONFIG) -set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") -configure_package_config_file( - "${CMAKE_CURRENT_LIST_DIR}/cmake/opentelemetry-cpp-config.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config.cmake" - INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" - PATH_VARS OPENTELEMETRY_ABI_VERSION_NO OPENTELEMETRY_VERSION PROJECT_NAME - INCLUDE_INSTALL_DIR 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}/${PROJECT_NAME}-config-version.cmake" - VERSION ${OPENTELEMETRY_VERSION} - COMPATIBILITY ExactVersion) - -install( - FILES +if(OPENTELEMETRY_INSTALL) + # Export cmake config and support find_packages(opentelemetry-cpp CONFIG) + # Write config file for find_packages(opentelemetry-cpp CONFIG) + set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") + configure_package_config_file( + "${CMAKE_CURRENT_LIST_DIR}/cmake/opentelemetry-cpp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" + PATH_VARS OPENTELEMETRY_ABI_VERSION_NO OPENTELEMETRY_VERSION PROJECT_NAME + INCLUDE_INSTALL_DIR 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}/${PROJECT_NAME}-config-version.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") - -# Export all components -export( - EXPORT "${PROJECT_NAME}-target" - NAMESPACE "${PROJECT_NAME}::" - FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-target.cmake" -) -install( - EXPORT "${PROJECT_NAME}-target" - NAMESPACE "${PROJECT_NAME}::" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") - -if(BUILD_PACKAGE) - include(cmake/package.cmake) - include(CPack) + VERSION ${OPENTELEMETRY_VERSION} + COMPATIBILITY ExactVersion) + + install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config-version.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") + + # Export all components + export( + EXPORT "${PROJECT_NAME}-target" + NAMESPACE "${PROJECT_NAME}::" + FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-target.cmake" + ) + install( + EXPORT "${PROJECT_NAME}-target" + NAMESPACE "${PROJECT_NAME}::" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") + + if(BUILD_PACKAGE) + include(cmake/package.cmake) + include(CPack) + endif() endif() diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 8a7b35806e..6b3f137056 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -9,31 +9,33 @@ target_include_directories( 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}) - -set(LOGS_EXCLUDE_PATTERN "") -if(NOT WITH_LOGS_PREVIEW) - set(LOGS_EXCLUDE_PATTERN "logs") -endif() +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_api + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + set(LOGS_EXCLUDE_PATTERN "") + if(NOT WITH_LOGS_PREVIEW) + set(LOGS_EXCLUDE_PATTERN "logs") + endif() -install( - DIRECTORY include/opentelemetry - DESTINATION include - FILES_MATCHING - PATTERN "*.h" - PATTERN "metrics" EXCLUDE) - -install( - DIRECTORY include/opentelemetry - DESTINATION include - FILES_MATCHING - PATTERN "*.h" - PATTERN "${LOGS_EXCLUDE_PATTERN}" EXCLUDE) + install( + DIRECTORY include/opentelemetry + DESTINATION include + FILES_MATCHING + PATTERN "*.h" + PATTERN "metrics" EXCLUDE) + + install( + DIRECTORY include/opentelemetry + DESTINATION include + FILES_MATCHING + PATTERN "*.h" + PATTERN "${LOGS_EXCLUDE_PATTERN}" EXCLUDE) +endif() if(BUILD_TESTING) add_subdirectory(test) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index faa3fdaf88..3c81ec8431 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -231,6 +231,21 @@ elif [[ "$1" == "cmake.exporter.otprotocol.with_async_export.test" ]]; then make -j $(nproc) cd exporters/otlp && make test exit 0 +elif [[ "$1" == "cmake.do_not_install.test" ]]; then + cd "${BUILD_DIR}" + rm -rf * + cmake -DCMAKE_BUILD_TYPE=Debug \ + -DWITH_OTLP=ON \ + -DWITH_OTLP_HTTP=ON \ + -DWITH_ASYNC_EXPORT_PREVIEW=ON \ + -DOPENTELEMETRY_INSTALL=OFF \ + "${SRC_DIR}" + grpc_cpp_plugin=`which grpc_cpp_plugin` + proto_make_file="CMakeFiles/opentelemetry_proto.dir/build.make" + sed -i "s~gRPC_CPP_PLUGIN_EXECUTABLE-NOTFOUND~$grpc_cpp_plugin~" ${proto_make_file} #fixme + make -j $(nproc) + cd exporters/otlp && make test + exit 0 elif [[ "$1" == "bazel.with_abseil" ]]; then bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS_ASYNC --//api:with_abseil=true //... bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_TEST_OPTIONS_ASYNC --//api:with_abseil=true //... diff --git a/cmake/nlohmann-json.cmake b/cmake/nlohmann-json.cmake index cffc7d6b2e..84f107b97c 100644 --- a/cmake/nlohmann-json.cmake +++ b/cmake/nlohmann-json.cmake @@ -2,36 +2,32 @@ # SPDX-License-Identifier: Apache-2.0 # -# The dependency on nlohmann_json can be provided different ways. -# By order of decreasing priority, options are: +# The dependency on nlohmann_json can be provided different ways. By order of +# decreasing priority, options are: # # 1 - Search for a nlohmann_json package # # Packages installed on the local machine are used if found. # -# The nlohmann_json dependency is not installed, -# as it already is. +# The nlohmann_json dependency is not installed, as it already is. # # 2 - Search for a nlohmann_json git submodule # -# When git submodule is used, -# the nlohmann_json code is located in: +# When git submodule is used, the nlohmann_json code is located in: # third_party/nlohmann-json # -# The nlohmann_json dependency is installed, -# by building the sub directory with JSON_Install=ON +# The nlohmann_json dependency is installed, by building the sub directory with +# JSON_Install=ON # # 3 - Download nlohmann_json from github # -# Code from the development branch is used, -# unless a specific release tag is provided -# in variable ${nlohmann-json} +# Code from the development branch is used, unless a specific release tag is +# provided in variable ${nlohmann-json} # -# The nlohmann_json dependency is installed, -# by building the downloaded code with JSON_Install=ON +# The nlohmann_json dependency is installed, by building the downloaded code +# with JSON_Install=ON # - # nlohmann_json package is required for most SDK build configurations find_package(nlohmann_json QUIET) set(nlohmann_json_clone FALSE) @@ -54,47 +50,42 @@ elseif(EXISTS ${PROJECT_SOURCE_DIR}/.git ${PROJECT_SOURCE_DIR}/third_party/nlohmann-json/single_include) else() if("${nlohmann-json}" STREQUAL "") - set(nlohmann-json "develop") + set(nlohmann-json "develop") endif() message(STATUS "nlohmann::json dependency satisfied by: github download") set(nlohmann_json_clone TRUE) include(ExternalProject) - ExternalProject_Add(nlohmann_json_download - PREFIX third_party - GIT_REPOSITORY https://github.com/nlohmann/json.git - GIT_TAG - "${nlohmann-json}" - UPDATE_COMMAND "" - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - -DJSON_BuildTests=OFF - -DJSON_Install=ON - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - TEST_AFTER_INSTALL - 0 - DOWNLOAD_NO_PROGRESS - 1 - LOG_CONFIGURE - 1 - LOG_BUILD - 1 - LOG_INSTALL - 1 - ) + ExternalProject_Add( + nlohmann_json_download + PREFIX third_party + GIT_REPOSITORY https://github.com/nlohmann/json.git + GIT_TAG "${nlohmann-json}" + UPDATE_COMMAND "" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + -DJSON_BuildTests=OFF -DJSON_Install=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + TEST_AFTER_INSTALL 0 + DOWNLOAD_NO_PROGRESS 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1) ExternalProject_Get_Property(nlohmann_json_download INSTALL_DIR) - SET(NLOHMANN_JSON_INCLUDE_DIR ${INSTALL_DIR}/src/nlohmann_json_download/single_include) + set(NLOHMANN_JSON_INCLUDE_DIR + ${INSTALL_DIR}/src/nlohmann_json_download/single_include) add_library(nlohmann_json_ INTERFACE) - target_include_directories(nlohmann_json_ INTERFACE - "$" - "$") + target_include_directories( + nlohmann_json_ INTERFACE "$" + "$") add_dependencies(nlohmann_json_ nlohmann_json_download) add_library(nlohmann_json::nlohmann_json ALIAS nlohmann_json_) - install( - TARGETS nlohmann_json_ - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + if(OPENTELEMETRY_INSTALL) + install( + TARGETS nlohmann_json_ + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() endif() diff --git a/cmake/opentelemetry-proto.cmake b/cmake/opentelemetry-proto.cmake index a21c0f16cf..1aa1ba0349 100644 --- a/cmake/opentelemetry-proto.cmake +++ b/cmake/opentelemetry-proto.cmake @@ -2,32 +2,33 @@ # SPDX-License-Identifier: Apache-2.0 # -# The dependency on opentelemetry-proto can be provided different ways. -# By order of decreasing priority, options are: +# The dependency on opentelemetry-proto can be provided different ways. By order +# of decreasing priority, options are: # # 1 - Use a provided package # # This is useful to build opentelemetry-cpp as part of a super project. # -# The super project provides the path to the opentelemetry-proto -# source code using variable ${OTELCPP_PROTO_PATH} +# The super project provides the path to the opentelemetry-proto source code +# using variable ${OTELCPP_PROTO_PATH} # # 2 - Search for a opentelemetry-proto git submodule # -# When git submodule is used, -# the opentelemetry-proto code is located in: +# When git submodule is used, the opentelemetry-proto code is located in: # third_party/opentelemetry-proto # # 3 - Download opentelemetry-proto from github # -# Code from the required version is used, -# unless a specific release tag is provided -# in variable ${opentelemetry-proto} +# Code from the required version is used, unless a specific release tag is +# provided in variable ${opentelemetry-proto} # if(OTELCPP_PROTO_PATH) - if(NOT EXISTS "${OTELCPP_PROTO_PATH}/opentelemetry/proto/common/v1/common.proto") - message(FATAL_ERROR "OTELCPP_PROTO_PATH does not point to a opentelemetry-proto repository") + if(NOT EXISTS + "${OTELCPP_PROTO_PATH}/opentelemetry/proto/common/v1/common.proto") + message( + FATAL_ERROR + "OTELCPP_PROTO_PATH does not point to a opentelemetry-proto repository") endif() message(STATUS "opentelemetry-proto dependency satisfied by: external path") set(PROTO_PATH ${OTELCPP_PROTO_PATH}) @@ -35,10 +36,12 @@ if(OTELCPP_PROTO_PATH) else() if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git) message(STATUS "opentelemetry-proto dependency satisfied by: git submodule") - set(PROTO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto") + set(PROTO_PATH + "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto") set(needs_proto_download FALSE) else() - message(STATUS "opentelemetry-proto dependency satisfied by: github download") + message( + STATUS "opentelemetry-proto dependency satisfied by: github download") if("${opentelemetry-proto}" STREQUAL "") set(opentelemetry-proto "v0.19.0") endif() @@ -259,18 +262,20 @@ endif() set_target_properties(opentelemetry_proto PROPERTIES EXPORT_NAME proto) patch_protobuf_targets(opentelemetry_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(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_proto + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install( - DIRECTORY ${GENERATED_PROTOBUF_PATH}/opentelemetry - DESTINATION include - FILES_MATCHING - PATTERN "*.h") + install( + DIRECTORY ${GENERATED_PROTOBUF_PATH}/opentelemetry + DESTINATION include + FILES_MATCHING + PATTERN "*.h") +endif() if(TARGET protobuf::libprotobuf) target_link_libraries(opentelemetry_proto PUBLIC protobuf::libprotobuf) diff --git a/exporters/elasticsearch/CMakeLists.txt b/exporters/elasticsearch/CMakeLists.txt index f83edb3ae2..94a12c62e0 100644 --- a/exporters/elasticsearch/CMakeLists.txt +++ b/exporters/elasticsearch/CMakeLists.txt @@ -17,19 +17,21 @@ target_link_libraries( PUBLIC opentelemetry_trace opentelemetry_logs opentelemetry_http_client_curl nlohmann_json::nlohmann_json) -install( - TARGETS opentelemetry_exporter_elasticsearch_logs - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -install( - DIRECTORY include/opentelemetry/exporters/elasticsearch - DESTINATION include/opentelemetry/exporters - FILES_MATCHING - PATTERN "*.h" - PATTERN "es_log_recordable.h" EXCLUDE) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_exporter_elasticsearch_logs + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + install( + DIRECTORY include/opentelemetry/exporters/elasticsearch + DESTINATION include/opentelemetry/exporters + FILES_MATCHING + PATTERN "*.h" + PATTERN "es_log_recordable.h" EXCLUDE) +endif() if(BUILD_TESTING) add_executable(es_log_record_exporter_test diff --git a/exporters/etw/CMakeLists.txt b/exporters/etw/CMakeLists.txt index 43f8b6bdb9..15ab6e8ebb 100644 --- a/exporters/etw/CMakeLists.txt +++ b/exporters/etw/CMakeLists.txt @@ -17,18 +17,20 @@ if(nlohmann_json_clone) add_dependencies(opentelemetry_exporter_etw nlohmann_json::nlohmann_json) endif() -install( - TARGETS opentelemetry_exporter_etw - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_exporter_etw + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install( - DIRECTORY include/opentelemetry/exporters/etw - DESTINATION include/opentelemetry/exporters - FILES_MATCHING - PATTERN "*.h") + install( + DIRECTORY include/opentelemetry/exporters/etw + DESTINATION include/opentelemetry/exporters + FILES_MATCHING + PATTERN "*.h") +endif() if(BUILD_TESTING) add_executable(etw_provider_test test/etw_provider_test.cc) diff --git a/exporters/jaeger/CMakeLists.txt b/exporters/jaeger/CMakeLists.txt index d40ba58527..62d2961324 100644 --- a/exporters/jaeger/CMakeLists.txt +++ b/exporters/jaeger/CMakeLists.txt @@ -55,19 +55,21 @@ if(MSVC) endif() endif() -install( - TARGETS opentelemetry_exporter_jaeger_trace - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -install( - DIRECTORY include/opentelemetry/exporters/jaeger - DESTINATION include/opentelemetry/exporters - FILES_MATCHING - PATTERN "*.h" - PATTERN "recordable.h" EXCLUDE) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_exporter_jaeger_trace + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + install( + DIRECTORY include/opentelemetry/exporters/jaeger + DESTINATION include/opentelemetry/exporters + FILES_MATCHING + PATTERN "*.h" + PATTERN "recordable.h" EXCLUDE) +endif() if(BUILD_TESTING) add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1) diff --git a/exporters/memory/CMakeLists.txt b/exporters/memory/CMakeLists.txt index 9082929498..36ddca5ac5 100644 --- a/exporters/memory/CMakeLists.txt +++ b/exporters/memory/CMakeLists.txt @@ -15,18 +15,20 @@ set_target_properties(opentelemetry_exporter_in_memory target_link_libraries(opentelemetry_exporter_in_memory PUBLIC opentelemetry_trace) -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(OPENTELEMETRY_INSTALL) + 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") +endif() 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 a3262dbc2a..a674de8442 100644 --- a/exporters/ostream/CMakeLists.txt +++ b/exporters/ostream/CMakeLists.txt @@ -14,18 +14,20 @@ target_include_directories( target_link_libraries(opentelemetry_exporter_ostream_span PUBLIC opentelemetry_trace) -install( - TARGETS opentelemetry_exporter_ostream_span - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS 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 - PATTERN "*.h" - PATTERN "log_Exporter.h" EXCLUDE) + install( + DIRECTORY include/opentelemetry/exporters/ostream + DESTINATION include/opentelemetry/exporters + PATTERN "*.h" + PATTERN "log_Exporter.h" EXCLUDE) +endif() if(BUILD_TESTING) add_executable(ostream_span_test test/ostream_span_test.cc) @@ -45,16 +47,20 @@ target_include_directories( PUBLIC "$") target_link_libraries(opentelemetry_exporter_ostream_metrics PUBLIC opentelemetry_metrics) -install( - TARGETS opentelemetry_exporter_ostream_metrics - 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 - PATTERN "metric_exporter.h") + +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_exporter_ostream_metrics + 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 + PATTERN "metric_exporter.h") +endif() + if(BUILD_TESTING) add_executable(ostream_metric_test test/ostream_metric_test.cc) target_link_libraries( @@ -75,16 +81,20 @@ if(WITH_LOGS_PREVIEW) PUBLIC "$") target_link_libraries(opentelemetry_exporter_ostream_logs PUBLIC opentelemetry_logs) - install( - TARGETS opentelemetry_exporter_ostream_logs - 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 - PATTERN "log_record_exporter.h") + + if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_exporter_ostream_logs + 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 + PATTERN "log_record_exporter.h") + endif() + if(BUILD_TESTING) add_executable(ostream_log_test test/ostream_log_test.cc) target_link_libraries(ostream_log_test ${GTEST_BOTH_LIBRARIES} diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index 7e654d3a30..585e253939 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -162,18 +162,20 @@ if(WITH_OTLP_HTTP) opentelemetry_exporter_otlp_http_metric) endif() -install( - TARGETS ${OPENTELEMETRY_OTLP_TARGETS} - 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") +if(OPENTELEMETRY_INSTALL) + install( + TARGETS ${OPENTELEMETRY_OTLP_TARGETS} + 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") +endif() if(BUILD_TESTING) add_executable(otlp_recordable_test test/otlp_recordable_test.cc) diff --git a/exporters/prometheus/CMakeLists.txt b/exporters/prometheus/CMakeLists.txt index d13298abeb..1e6c79e376 100644 --- a/exporters/prometheus/CMakeLists.txt +++ b/exporters/prometheus/CMakeLists.txt @@ -26,18 +26,21 @@ endif() target_link_libraries( opentelemetry_exporter_prometheus PUBLIC opentelemetry_metrics prometheus-cpp::pull prometheus-cpp::core) -install( - TARGETS ${PROMETHEUS_EXPORTER_TARGETS} - 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(OPENTELEMETRY_INSTALL) + install( + TARGETS ${PROMETHEUS_EXPORTER_TARGETS} + 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") +endif() if(BUILD_TESTING) add_subdirectory(test) diff --git a/exporters/zipkin/CMakeLists.txt b/exporters/zipkin/CMakeLists.txt index ba74ba17b6..68836cc8d3 100644 --- a/exporters/zipkin/CMakeLists.txt +++ b/exporters/zipkin/CMakeLists.txt @@ -12,19 +12,21 @@ target_link_libraries( PUBLIC opentelemetry_trace opentelemetry_http_client_curl nlohmann_json::nlohmann_json) -install( - TARGETS opentelemetry_exporter_zipkin_trace - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_exporter_zipkin_trace + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install( - DIRECTORY include/opentelemetry/exporters/zipkin - DESTINATION include/opentelemetry/exporters - FILES_MATCHING - PATTERN "*.h" - PATTERN "recordable.h" EXCLUDE) + install( + DIRECTORY include/opentelemetry/exporters/zipkin + DESTINATION include/opentelemetry/exporters + FILES_MATCHING + PATTERN "*.h" + PATTERN "recordable.h" EXCLUDE) +endif() if(BUILD_TESTING) add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1) diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index 2242f5b132..bae59e3040 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -10,18 +10,20 @@ target_include_directories( set_target_properties(opentelemetry_ext PROPERTIES EXPORT_NAME "ext") target_link_libraries(opentelemetry_ext INTERFACE opentelemetry_api) -install( - TARGETS opentelemetry_ext - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if(OPENTELEMETRY_INSTALL) + 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") + install( + DIRECTORY include/opentelemetry/ext + DESTINATION include/opentelemetry/ + FILES_MATCHING + PATTERN "*.h") +endif() add_subdirectory(src) diff --git a/ext/src/dll/CMakeLists.txt b/ext/src/dll/CMakeLists.txt index 7f34fab142..4cfcd87412 100644 --- a/ext/src/dll/CMakeLists.txt +++ b/ext/src/dll/CMakeLists.txt @@ -45,9 +45,11 @@ add_custom_command( ${OPENTELEMETRY_EXPORT_DEF} COMMAND_EXPAND_LISTS VERBATIM) -install( - TARGETS opentelemetry_cpp - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_cpp + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() diff --git a/ext/src/http/client/curl/CMakeLists.txt b/ext/src/http/client/curl/CMakeLists.txt index 38fdad4030..6684c5f820 100644 --- a/ext/src/http/client/curl/CMakeLists.txt +++ b/ext/src/http/client/curl/CMakeLists.txt @@ -22,9 +22,11 @@ else() PRIVATE ${CURL_LIBRARIES}) endif() -install( - TARGETS opentelemetry_http_client_curl - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_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/ext/src/zpages/CMakeLists.txt b/ext/src/zpages/CMakeLists.txt index c7b9e880de..5237d2da9b 100644 --- a/ext/src/zpages/CMakeLists.txt +++ b/ext/src/zpages/CMakeLists.txt @@ -16,9 +16,11 @@ set_target_properties(opentelemetry_zpages PROPERTIES EXPORT_NAME zpages) target_link_libraries(opentelemetry_zpages PUBLIC opentelemetry_ext 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}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_zpages + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() diff --git a/opentracing-shim/CMakeLists.txt b/opentracing-shim/CMakeLists.txt index 2e89fca540..3a57ac07bf 100644 --- a/opentracing-shim/CMakeLists.txt +++ b/opentracing-shim/CMakeLists.txt @@ -23,18 +23,20 @@ else() OpenTracing::opentracing) endif() -install( - TARGETS ${this_target} - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -install( - DIRECTORY include/opentelemetry/opentracingshim - DESTINATION include/opentelemetry - FILES_MATCHING - PATTERN "*.h") +if(OPENTELEMETRY_INSTALL) + install( + TARGETS ${this_target} + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + install( + DIRECTORY include/opentelemetry/opentracingshim + DESTINATION include/opentelemetry + FILES_MATCHING + PATTERN "*.h") +endif() if(BUILD_TESTING) foreach(testname propagation_test shim_utils_test span_shim_test diff --git a/sdk/CMakeLists.txt b/sdk/CMakeLists.txt index 98f15e2b6b..2e8f3bb61d 100644 --- a/sdk/CMakeLists.txt +++ b/sdk/CMakeLists.txt @@ -9,31 +9,33 @@ target_include_directories( 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/ - DESTINATION include/opentelemetry - FILES_MATCHING - PATTERN "*config.h") - -set(LOGS_EXCLUDE_PATTERN "") -if(NOT WITH_LOGS_PREVIEW) - set(LOGS_EXCLUDE_PATTERN "logs") +if(OPENTELEMETRY_INSTALL) + 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/ + DESTINATION include/opentelemetry + FILES_MATCHING + PATTERN "*config.h") + + set(LOGS_EXCLUDE_PATTERN "") + if(NOT WITH_LOGS_PREVIEW) + set(LOGS_EXCLUDE_PATTERN "logs") + endif() + + install( + DIRECTORY include/opentelemetry/sdk + DESTINATION include/opentelemetry + FILES_MATCHING + PATTERN "*.h" + PATTERN "${LOGS_EXCLUDE_PATTERN}" EXCLUDE) endif() -install( - DIRECTORY include/opentelemetry/sdk - DESTINATION include/opentelemetry - FILES_MATCHING - PATTERN "*.h" - PATTERN "${LOGS_EXCLUDE_PATTERN}" EXCLUDE) - add_subdirectory(src) if(BUILD_TESTING) diff --git a/sdk/src/common/CMakeLists.txt b/sdk/src/common/CMakeLists.txt index 4caf9e048c..b23a93e80c 100644 --- a/sdk/src/common/CMakeLists.txt +++ b/sdk/src/common/CMakeLists.txt @@ -16,9 +16,11 @@ target_link_libraries( opentelemetry_common PUBLIC opentelemetry_api opentelemetry_sdk Threads::Threads) -install( - TARGETS opentelemetry_common - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_common + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() diff --git a/sdk/src/logs/CMakeLists.txt b/sdk/src/logs/CMakeLists.txt index 8c279705d6..cbaea426e6 100644 --- a/sdk/src/logs/CMakeLists.txt +++ b/sdk/src/logs/CMakeLists.txt @@ -30,9 +30,11 @@ 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}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_logs + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() diff --git a/sdk/src/metrics/CMakeLists.txt b/sdk/src/metrics/CMakeLists.txt index 138c5d4c4f..f53639332b 100644 --- a/sdk/src/metrics/CMakeLists.txt +++ b/sdk/src/metrics/CMakeLists.txt @@ -29,9 +29,11 @@ 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}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_metrics + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() diff --git a/sdk/src/resource/CMakeLists.txt b/sdk/src/resource/CMakeLists.txt index d5f1cee5ec..f39b6f2a8f 100644 --- a/sdk/src/resource/CMakeLists.txt +++ b/sdk/src/resource/CMakeLists.txt @@ -11,9 +11,11 @@ target_include_directories( opentelemetry_resources PUBLIC "$") -install( - TARGETS opentelemetry_resources - EXPORT "${PROJECT_NAME}-target" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_resources + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() diff --git a/sdk/src/trace/CMakeLists.txt b/sdk/src/trace/CMakeLists.txt index e48955a19c..7f757f036c 100644 --- a/sdk/src/trace/CMakeLists.txt +++ b/sdk/src/trace/CMakeLists.txt @@ -30,9 +30,11 @@ 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}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_trace + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() diff --git a/sdk/src/version/CMakeLists.txt b/sdk/src/version/CMakeLists.txt index a0f4a2f453..d8c48ed96d 100644 --- a/sdk/src/version/CMakeLists.txt +++ b/sdk/src/version/CMakeLists.txt @@ -12,9 +12,11 @@ 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}) +if(OPENTELEMETRY_INSTALL) + install( + TARGETS opentelemetry_version + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif()