Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ if(WITH_EXAMPLES_HTTP AND NOT WITH_EXAMPLES)
message(FATAL_ERROR "WITH_EXAMPLES_HTTP=ON requires WITH_EXAMPLES=ON")
endif()

if(WITH_GSL)
include("${opentelemetry-cpp_SOURCE_DIR}/cmake/ms-gsl.cmake")
endif()

find_package(Threads)

function(set_target_version target_name)
Expand Down Expand Up @@ -678,7 +682,9 @@ message(STATUS "CMake: ${CMAKE_VERSION}")
message(STATUS "GTest: ${GTest_VERSION} (${GTest_PROVIDER})")
message(STATUS "benchmark: ${benchmark_VERSION} (${benchmark_PROVIDER})")
if(WITH_GSL)
message(STATUS "GSL: ${GSL_VERSION}")
message(
STATUS "Microsoft.GSL: ${Microsoft.GSL_VERSION} (${Microsoft.GSL_PROVIDER})"
)
endif()
if(absl_FOUND)
message(STATUS "Abseil: ${absl_VERSION}")
Expand Down
44 changes: 16 additions & 28 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,7 @@ target_include_directories(

set_target_properties(opentelemetry_api PROPERTIES EXPORT_NAME api)

otel_add_component(
COMPONENT
api
TARGETS
opentelemetry_api
FILES_DIRECTORY
"include/opentelemetry"
FILES_DESTINATION
"include"
FILES_MATCHING
PATTERN
"*.h")

if(OPENTELEMETRY_INSTALL)
unset(TARGET_DEPS)
endif()
unset(TARGET_DEPS)

if(BUILD_TESTING)
add_subdirectory(test)
Expand Down Expand Up @@ -74,18 +59,8 @@ endif()

if(WITH_GSL)
target_compile_definitions(opentelemetry_api INTERFACE HAVE_GSL)

# Guidelines Support Library path. Used if we are not on not get C++20.
#
find_package(Microsoft.GSL QUIET)
if(TARGET Microsoft.GSL::GSL)
target_link_libraries(opentelemetry_api INTERFACE Microsoft.GSL::GSL)
list(APPEND TARGET_DEPS "gsl")
else()
set(GSL_DIR third_party/ms-gsl)
target_include_directories(
opentelemetry_api INTERFACE "$<BUILD_INTERFACE:${GSL_DIR}/include>")
endif()
target_link_libraries(opentelemetry_api INTERFACE Microsoft.GSL::GSL)
list(APPEND TARGET_DEPS "gsl")
endif()

if(WITH_NO_GETENV)
Expand Down Expand Up @@ -140,6 +115,19 @@ if(APPLE)
target_link_libraries(opentelemetry_api INTERFACE "-framework CoreFoundation")
endif()

otel_add_component(
COMPONENT
api
TARGETS
opentelemetry_api
FILES_DIRECTORY
"include/opentelemetry"
FILES_DESTINATION
"include"
FILES_MATCHING
PATTERN
"*.h")

include(${PROJECT_SOURCE_DIR}/cmake/pkgconfig.cmake)

if(OPENTELEMETRY_INSTALL)
Expand Down
1 change: 1 addition & 0 deletions ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ switch ($action) {
"-DCMAKE_INSTALL_PREFIX=$INSTALL_TEST_DIR" `
-DWITH_ABI_VERSION_1=OFF `
-DWITH_ABI_VERSION_2=ON `
-DWITH_GSL=ON `
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON `
-DWITH_METRICS_EXEMPLAR_PREVIEW=ON `
-DWITH_ASYNC_EXPORT_PREVIEW=ON `
Expand Down
3 changes: 3 additions & 0 deletions ci/setup_windows_ci_environment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ $VCPKG_DIR = (Get-Item -Path ".\").FullName
./bootstrap-vcpkg.bat
./vcpkg integrate install

# Microsoft.GSL
./vcpkg "--vcpkg-root=$VCPKG_DIR" install ms-gsl:x64-windows

# Google Benchmark
./vcpkg "--vcpkg-root=$VCPKG_DIR" install benchmark:x64-windows

Expand Down
35 changes: 35 additions & 0 deletions cmake/ms-gsl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

find_package(Microsoft.GSL CONFIG QUIET)
set(Microsoft.GSL_PROVIDER "find_package")

if(NOT Microsoft.GSL_FOUND)
set(_Microsoft.GSL_SUBMODULE_DIR "${opentelemetry-cpp_SOURCE_DIR}/third_party/ms-gsl")
if(EXISTS "${_Microsoft.GSL_SUBMODULE_DIR}/.git")
FetchContent_Declare(
"gsl"
SOURCE_DIR "${_Microsoft.GSL_SUBMODULE_DIR}"
)
set(Microsoft.GSL_PROVIDER "fetch_source")
else()
FetchContent_Declare(
"gsl"
GIT_REPOSITORY "https://github.com/microsoft/GSL.git"
GIT_TAG "${ms-gsl_GIT_TAG}"
)
set(Microsoft.GSL_PROVIDER "fetch_repository")
endif()

set(GSL_TEST OFF CACHE BOOL "" FORCE)
set(GSL_INSTALL ${OPENTELEMETRY_INSTALL} CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(gsl)

# Set the Microsoft.GSL_VERSION variable from the git tag.
string(REGEX REPLACE "^v([0-9]+\\.[0-9]+\\.[0-9]+)$" "\\1" Microsoft.GSL_VERSION "${ms-gsl_GIT_TAG}")
endif()

if(NOT TARGET Microsoft.GSL::GSL)
message(FATAL_ERROR "A required Microsoft.GSL target Microsoft.GSL::GSL was not imported")
endif()
2 changes: 2 additions & 0 deletions cmake/thirdparty-dependency-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#-----------------------------------------------------------------------
set(OTEL_THIRDPARTY_DEPENDENCIES_SUPPORTED
Threads
Microsoft.GSL
ZLIB
CURL
nlohmann_json
Expand All @@ -29,6 +30,7 @@ set(OTEL_Protobuf_TARGET_NAMESPACE "protobuf")
# # set(OTEL_<dependency>_SEARCH_MODE "<search mode>")
#-----------------------------------------------------------------------
set(OTEL_Threads_SEARCH_MODE "")
set(OTEL_Microsoft.GSL_SEARCH_MODE "CONFIG")
set(OTEL_ZLIB_SEARCH_MODE "")
set(OTEL_CURL_SEARCH_MODE "")
set(OTEL_nlohmann_json_SEARCH_MODE "CONFIG")
Expand Down
Loading