File tree Expand file tree Collapse file tree 6 files changed +64
-29
lines changed
Expand file tree Collapse file tree 6 files changed +64
-29
lines changed Original file line number Diff line number Diff line change @@ -284,6 +284,10 @@ if(WITH_EXAMPLES_HTTP AND NOT WITH_EXAMPLES)
284284 message (FATAL_ERROR "WITH_EXAMPLES_HTTP=ON requires WITH_EXAMPLES=ON" )
285285endif ()
286286
287+ if (WITH_GSL)
288+ include ("${opentelemetry-cpp_SOURCE_DIR}/cmake/ms-gsl.cmake" )
289+ endif ()
290+
287291find_package (Threads)
288292
289293function (set_target_version target_name)
@@ -678,7 +682,9 @@ message(STATUS "CMake: ${CMAKE_VERSION}")
678682message (STATUS "GTest: ${GTest_VERSION} (${GTest_PROVIDER} )" )
679683message (STATUS "benchmark: ${benchmark_VERSION} (${benchmark_PROVIDER} )" )
680684if (WITH_GSL)
681- message (STATUS "GSL: ${GSL_VERSION} " )
685+ message (
686+ STATUS "Microsoft.GSL: ${Microsoft.GSL_VERSION} (${Microsoft.GSL_PROVIDER})"
687+ )
682688endif ()
683689if (absl_FOUND)
684690 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 @@ -10,6 +10,9 @@ $VCPKG_DIR = (Get-Item -Path ".\").FullName
1010./ bootstrap-vcpkg.bat
1111./ vcpkg integrate install
1212
13+ # Microsoft.GSL
14+ ./ vcpkg " --vcpkg-root=$VCPKG_DIR " install ms- gsl:x64- windows
15+
1316# Google Benchmark
1417./ vcpkg " --vcpkg-root=$VCPKG_DIR " install benchmark:x64- windows
1518
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