File tree Expand file tree Collapse file tree 5 files changed +61
-29
lines changed Expand file tree Collapse file tree 5 files changed +61
-29
lines changed Original file line number Diff line number Diff line change @@ -275,6 +275,10 @@ if(WITH_EXAMPLES_HTTP AND NOT WITH_EXAMPLES)
275275 message (FATAL_ERROR "WITH_EXAMPLES_HTTP=ON requires WITH_EXAMPLES=ON" )
276276endif ()
277277
278+ if (WITH_GSL)
279+ include ("${opentelemetry-cpp_SOURCE_DIR}/cmake/ms-gsl.cmake" )
280+ endif ()
281+
278282find_package (Threads)
279283
280284function (set_target_version target_name)
@@ -635,7 +639,9 @@ message(STATUS "CMake: ${CMAKE_VERSION}")
635639message (STATUS "GTest: ${GTest_VERSION} (${GTest_PROVIDER} )" )
636640message (STATUS "benchmark: ${benchmark_VERSION} (${benchmark_PROVIDER} )" )
637641if (WITH_GSL)
638- message (STATUS "GSL: ${GSL_VERSION} " )
642+ message (
643+ STATUS "Microsoft.GSL: ${Microsoft.GSL_VERSION} (${Microsoft.GSL_PROVIDER})"
644+ )
639645endif ()
640646if (absl_FOUND)
641647 message (STATUS "Abseil: ${absl_VERSION} " )
Original file line number Diff line number Diff line change @@ -9,22 +9,7 @@ target_include_directories(
99
1010set_target_properties (opentelemetry_api PROPERTIES EXPORT_NAME api)
1111
12- otel_add_component(
13- COMPONENT
14- api
15- TARGETS
16- opentelemetry_api
17- FILES_DIRECTORY
18- "include/opentelemetry"
19- FILES_DESTINATION
20- "include"
21- FILES_MATCHING
22- PATTERN
23- "*.h" )
24-
25- if (OPENTELEMETRY_INSTALL)
26- unset (TARGET_DEPS)
27- endif ()
12+ unset (TARGET_DEPS)
2813
2914if (BUILD_TESTING)
3015 add_subdirectory (test )
@@ -74,18 +59,8 @@ endif()
7459
7560if (WITH_GSL)
7661 target_compile_definitions (opentelemetry_api INTERFACE HAVE_GSL)
77-
78- # Guidelines Support Library path. Used if we are not on not get C++20.
79- #
80- find_package (Microsoft.GSL QUIET )
81- if (TARGET Microsoft.GSL::GSL)
82- target_link_libraries (opentelemetry_api INTERFACE Microsoft.GSL::GSL)
83- list (APPEND TARGET_DEPS "gsl" )
84- else ()
85- set (GSL_DIR third_party/ms-gsl)
86- target_include_directories (
87- opentelemetry_api INTERFACE "$<BUILD_INTERFACE:${GSL_DIR} /include>" )
88- endif ()
62+ target_link_libraries (opentelemetry_api INTERFACE Microsoft.GSL::GSL)
63+ list (APPEND TARGET_DEPS "gsl" )
8964endif ()
9065
9166if (WITH_NO_GETENV)
@@ -140,6 +115,19 @@ if(APPLE)
140115 target_link_libraries (opentelemetry_api INTERFACE "-framework CoreFoundation" )
141116endif ()
142117
118+ otel_add_component(
119+ COMPONENT
120+ api
121+ TARGETS
122+ opentelemetry_api
123+ FILES_DIRECTORY
124+ "include/opentelemetry"
125+ FILES_DESTINATION
126+ "include"
127+ FILES_MATCHING
128+ PATTERN
129+ "*.h" )
130+
143131include (${PROJECT_SOURCE_DIR} /cmake/pkgconfig.cmake)
144132
145133if (OPENTELEMETRY_INSTALL)
Original file line number Diff line number Diff line change @@ -344,6 +344,7 @@ switch ($action) {
344344 " -DCMAKE_INSTALL_PREFIX=$INSTALL_TEST_DIR " `
345345 - DWITH_ABI_VERSION_1= OFF `
346346 - DWITH_ABI_VERSION_2= ON `
347+ - DWITH_GSL= ON `
347348 - DWITH_THREAD_INSTRUMENTATION_PREVIEW= ON `
348349 - DWITH_METRICS_EXEMPLAR_PREVIEW= ON `
349350 - DWITH_ASYNC_EXPORT_PREVIEW= ON `
Original file line number Diff line number Diff line change 1+ # Copyright The OpenTelemetry Authors
2+ # SPDX-License-Identifier: Apache-2.0
3+
4+ find_package (Microsoft.GSL CONFIG QUIET )
5+ set (Microsoft.GSL_PROVIDER "find_package" )
6+
7+ if (NOT Microsoft.GSL_FOUND)
8+ set (_Microsoft.GSL_SUBMODULE_DIR "${opentelemetry-cpp_SOURCE_DIR}/third_party/ms-gsl" )
9+ if (EXISTS "${_Microsoft.GSL_SUBMODULE_DIR}/.git" )
10+ FetchContent_Declare(
11+ "gsl"
12+ SOURCE_DIR "${_Microsoft.GSL_SUBMODULE_DIR}"
13+ )
14+ set (Microsoft.GSL_PROVIDER "fetch_source" )
15+ else ()
16+ FetchContent_Declare(
17+ "gsl"
18+ GIT_REPOSITORY "https://github.com/microsoft/GSL.git"
19+ GIT_TAG "${ms-gsl_GIT_TAG}"
20+ )
21+ set (Microsoft.GSL_PROVIDER "fetch_repository" )
22+ endif ()
23+
24+ set (GSL_TEST OFF CACHE BOOL "" FORCE)
25+ set (GSL_INSTALL ${OPENTELEMETRY_INSTALL} CACHE BOOL "" FORCE)
26+
27+ FetchContent_MakeAvailable(gsl)
28+
29+ # Set the Microsoft.GSL_VERSION variable from the git tag.
30+ string (REGEX REPLACE "^v([0-9]+\\ .[0-9]+\\ .[0-9]+)$" "\\ 1" Microsoft.GSL_VERSION "${ms-gsl_GIT_TAG}" )
31+ endif ()
32+
33+ if (NOT TARGET Microsoft.GSL::GSL)
34+ message (FATAL_ERROR "A required Microsoft.GSL target Microsoft.GSL::GSL was not imported" )
35+ endif ()
Original file line number Diff line number Diff line change 88#-----------------------------------------------------------------------
99set (OTEL_THIRDPARTY_DEPENDENCIES_SUPPORTED
1010 Threads
11+ Microsoft.GSL
1112 ZLIB
1213 CURL
1314 nlohmann_json
@@ -29,6 +30,7 @@ set(OTEL_Protobuf_TARGET_NAMESPACE "protobuf")
2930# # set(OTEL_<dependency>_SEARCH_MODE "<search mode>")
3031#-----------------------------------------------------------------------
3132set (OTEL_Threads_SEARCH_MODE "" )
33+ set (OTEL_Microsoft.GSL_SEARCH_MODE "CONFIG" )
3234set (OTEL_ZLIB_SEARCH_MODE "" )
3335set (OTEL_CURL_SEARCH_MODE "" )
3436set (OTEL_nlohmann_json_SEARCH_MODE "CONFIG" )
You can’t perform that action at this time.
0 commit comments