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)
275
275
message (FATAL_ERROR "WITH_EXAMPLES_HTTP=ON requires WITH_EXAMPLES=ON" )
276
276
endif ()
277
277
278
+ if (WITH_GSL )
279
+ include ("${opentelemetry-cpp_SOURCE_DIR}/cmake/ms-gsl.cmake" )
280
+ endif ()
281
+
278
282
find_package (Threads )
279
283
280
284
function (set_target_version target_name )
@@ -635,7 +639,9 @@ message(STATUS "CMake: ${CMAKE_VERSION}")
635
639
message (STATUS "GTest: ${GTest_VERSION} (${GTest_PROVIDER} )" )
636
640
message (STATUS "benchmark: ${benchmark_VERSION} (${benchmark_PROVIDER} )" )
637
641
if (WITH_GSL )
638
- message (STATUS "GSL: ${GSL_VERSION} " )
642
+ message (
643
+ STATUS "Microsoft.GSL: ${Microsoft.GSL_VERSION} (${Microsoft.GSL_PROVIDER})"
644
+ )
639
645
endif ()
640
646
if (absl_FOUND )
641
647
message (STATUS "Abseil: ${absl_VERSION} " )
Original file line number Diff line number Diff line change @@ -9,22 +9,7 @@ target_include_directories(
9
9
10
10
set_target_properties (opentelemetry_api PROPERTIES EXPORT_NAME api )
11
11
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 )
28
13
29
14
if (BUILD_TESTING )
30
15
add_subdirectory (test )
@@ -74,18 +59,8 @@ endif()
74
59
75
60
if (WITH_GSL )
76
61
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" )
89
64
endif ()
90
65
91
66
if (WITH_NO_GETENV )
@@ -140,6 +115,19 @@ if(APPLE)
140
115
target_link_libraries (opentelemetry_api INTERFACE "-framework CoreFoundation" )
141
116
endif ()
142
117
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
+
143
131
include (${PROJECT_SOURCE_DIR} /cmake/pkgconfig.cmake )
144
132
145
133
if (OPENTELEMETRY_INSTALL )
Original file line number Diff line number Diff line change @@ -344,6 +344,7 @@ switch ($action) {
344
344
" -DCMAKE_INSTALL_PREFIX=$INSTALL_TEST_DIR " `
345
345
- DWITH_ABI_VERSION_1= OFF `
346
346
- DWITH_ABI_VERSION_2= ON `
347
+ - DWITH_GSL= ON `
347
348
- DWITH_THREAD_INSTRUMENTATION_PREVIEW= ON `
348
349
- DWITH_METRICS_EXEMPLAR_PREVIEW= ON `
349
350
- 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 8
8
#-----------------------------------------------------------------------
9
9
set (OTEL_THIRDPARTY_DEPENDENCIES_SUPPORTED
10
10
Threads
11
+ Microsoft.GSL
11
12
ZLIB
12
13
CURL
13
14
nlohmann_json
@@ -29,6 +30,7 @@ set(OTEL_Protobuf_TARGET_NAMESPACE "protobuf")
29
30
# # set(OTEL_<dependency>_SEARCH_MODE "<search mode>")
30
31
#-----------------------------------------------------------------------
31
32
set (OTEL_Threads_SEARCH_MODE "" )
33
+ set (OTEL_Microsoft.GSL_SEARCH_MODE "CONFIG" )
32
34
set (OTEL_ZLIB_SEARCH_MODE "" )
33
35
set (OTEL_CURL_SEARCH_MODE "" )
34
36
set (OTEL_nlohmann_json_SEARCH_MODE "CONFIG" )
You can’t perform that action at this time.
0 commit comments