OpenTelemetry vcpkg fixes (#3716)
* OpenTelemetry vcpkg fixes * Update ci.yml * Drop version >= from project-level vcpkg * find_package only supports numeric versions * include(AzureBuildTargetForCI) * Do not build as Windows/UWP DLL * Docs and package dependencies * Update condition * Move condition down * Move more under condition * Rephrase condition * Try hack for CI that won't affect vcpkg Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
This commit is contained in:
parent
15f897c4e9
commit
f391e45bc1
@ -10,6 +10,10 @@ az_vcpkg_integrate()
|
||||
cmake_minimum_required (VERSION 3.12)
|
||||
project(azure-core-tracing-opentelemetry LANGUAGES CXX)
|
||||
|
||||
if (NOT VCPKG_TARGET_TRIPLET MATCHES "windows" OR VCPKG_TARGET_TRIPLET MATCHES "static" OR NOT WIN32)
|
||||
set(BUILD_AZURE_CORE_TRACING_OPENTELEMETRY ON)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
@ -23,66 +27,69 @@ include(AzureConfigRTTI)
|
||||
# Add create_map_file function
|
||||
include(CreateMapFile)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
if (BUILD_AZURE_CORE_TRACING_OPENTELEMETRY)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if(NOT AZ_ALL_LIBRARIES)
|
||||
find_package(azure-core-cpp "1.5.0" CONFIG QUIET)
|
||||
if(NOT azure-core-cpp_FOUND)
|
||||
find_package(azure-core-cpp "1.5.0" REQUIRED)
|
||||
endif()
|
||||
if(NOT AZ_ALL_LIBRARIES)
|
||||
find_package(azure-core-cpp CONFIG QUIET)
|
||||
if(NOT azure-core-cpp_FOUND)
|
||||
find_package(azure-core-cpp REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
find_package(opentelemetry-cpp "1.3.0" CONFIG REQUIRED)
|
||||
|
||||
set(
|
||||
AZURE_CORE_OPENTELEMETRY_HEADER
|
||||
inc/azure/core/tracing/opentelemetry/opentelemetry.hpp
|
||||
)
|
||||
|
||||
set(
|
||||
AZURE_CORE_OPENTELEMETRY_SOURCE
|
||||
src/opentelemetry.cpp
|
||||
)
|
||||
|
||||
add_library(azure-core-tracing-opentelemetry ${AZURE_CORE_OPENTELEMETRY_HEADER} ${AZURE_CORE_OPENTELEMETRY_SOURCE})
|
||||
|
||||
target_include_directories(
|
||||
azure-core-tracing-opentelemetry
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
# make sure that users can consume the project as a library.
|
||||
add_library(Azure::azure-core-tracing-opentelemetry ALIAS azure-core-tracing-opentelemetry)
|
||||
|
||||
# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF
|
||||
create_code_coverage(core azure-core-tracing-opentelemetry azure-core-tracing-opentelemetry-test "tests?/*;samples?/*")
|
||||
|
||||
target_link_libraries(azure-core-tracing-opentelemetry INTERFACE Threads::Threads)
|
||||
|
||||
target_link_libraries(azure-core-tracing-opentelemetry PRIVATE azure-core
|
||||
opentelemetry-cpp::api
|
||||
opentelemetry-cpp::ext
|
||||
opentelemetry-cpp::sdk
|
||||
opentelemetry-cpp::trace)
|
||||
endif()
|
||||
find_package(opentelemetry-cpp "1.3.0" CONFIG REQUIRED)
|
||||
|
||||
set(
|
||||
AZURE_CORE_OPENTELEMETRY_HEADER
|
||||
inc/azure/core/tracing/opentelemetry/opentelemetry.hpp
|
||||
)
|
||||
|
||||
set(
|
||||
AZURE_CORE_OPENTELEMETRY_SOURCE
|
||||
src/opentelemetry.cpp
|
||||
)
|
||||
|
||||
add_library(azure-core-tracing-opentelemetry ${AZURE_CORE_OPENTELEMETRY_HEADER} ${AZURE_CORE_OPENTELEMETRY_SOURCE})
|
||||
|
||||
target_include_directories(
|
||||
azure-core-tracing-opentelemetry
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
# make sure that users can consume the project as a library.
|
||||
add_library(Azure::azure-core-tracing-opentelemetry ALIAS azure-core-tracing-opentelemetry)
|
||||
|
||||
# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF
|
||||
create_code_coverage(core azure-core-tracing-opentelemetry azure-core-tracing-opentelemetry-test "tests?/*;samples?/*")
|
||||
|
||||
target_link_libraries(azure-core-tracing-opentelemetry INTERFACE Threads::Threads)
|
||||
|
||||
target_link_libraries(azure-core-tracing-opentelemetry PRIVATE azure-core
|
||||
opentelemetry-cpp::api
|
||||
opentelemetry-cpp::ext
|
||||
opentelemetry-cpp::sdk
|
||||
opentelemetry-cpp::trace)
|
||||
|
||||
|
||||
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private/package_version.hpp")
|
||||
generate_documentation(azure-core-opentelemetry ${AZ_LIBRARY_VERSION})
|
||||
generate_documentation(azure-core-tracing-opentelemetry ${AZ_LIBRARY_VERSION})
|
||||
|
||||
az_vcpkg_export(
|
||||
if(BUILD_AZURE_CORE_TRACING_OPENTELEMETRY)
|
||||
az_vcpkg_export(
|
||||
azure-core-tracing-opentelemetry
|
||||
CORE_TRACING_OPENTELEMETRY
|
||||
"azure/core/tracing/opentelemetry/dll_import_export.hpp"
|
||||
)
|
||||
|
||||
az_rtti_setup(
|
||||
azure-core-tracing-opentelemetry
|
||||
CORE_TRACING_OPENTELEMETRY
|
||||
"azure/core/tracing/opentelemetry/rtti.hpp"
|
||||
)
|
||||
az_rtti_setup(
|
||||
azure-core-tracing-opentelemetry
|
||||
CORE_TRACING_OPENTELEMETRY
|
||||
"azure/core/tracing/opentelemetry/rtti.hpp"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
if(BUILD_AZURE_CORE_TRACING_OPENTELEMETRY AND BUILD_TESTING)
|
||||
# define a symbol that enables some test hooks in code
|
||||
add_compile_definitions(TESTING_BUILD)
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ Then, use in your CMake file:
|
||||
|
||||
```CMake
|
||||
find_package(azure-core-tracing-opentelemetry-cpp CONFIG REQUIRED)
|
||||
target_link_libraries(<your project name> PRIVATE Azure::azure-core-opentelemetry)
|
||||
target_link_libraries(<your project name> PRIVATE Azure::azure-core-tracing-opentelemetry)
|
||||
```
|
||||
|
||||
## Key concepts
|
||||
@ -39,7 +39,7 @@ below for more details.
|
||||
### OpenTelemetry Compatibility
|
||||
|
||||
Most Azure SDKs use [OpenTelemetry](https://opentelemetry.io/) to support tracing. Specifically, we depend on
|
||||
the [azure-core-opentelemetry](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/building-with-vcpkg.md) VCPKG package.
|
||||
the [opentelemetry-cpp](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/building-with-vcpkg.md) VCPKG package.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
@ -13,6 +13,7 @@ project (azure-core-tracing-opentelemetry-test LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
include(AzureBuildTargetForCI)
|
||||
include(GoogleTest)
|
||||
|
||||
add_executable (
|
||||
@ -51,9 +52,9 @@ target_link_libraries(azure-core-tracing-opentelemetry-test PRIVATE azure-core-t
|
||||
create_per_service_target_build(core azure-core-tracing-opentelemetry-test)
|
||||
create_map_file(azure-core-tracing-opentelemetry-test azure-core-tracing-opentelemetry-test.map)
|
||||
|
||||
# gtest_discover_tests will scan the test from azure-core-opentelemetry-test and call add_test
|
||||
# gtest_discover_tests will scan the test from azure-core-tracing-opentelemetry-test and call add_test
|
||||
# for each test to ctest. This enables `ctest -r` to run specific tests directly.
|
||||
gtest_discover_tests(azure-core-tracing-opentelemetry-test
|
||||
TEST_PREFIX azure-core-opentelemetry.
|
||||
TEST_PREFIX azure-core-tracing-opentelemetry.
|
||||
NO_PRETTY_TYPES
|
||||
NO_PRETTY_VALUES)
|
||||
|
||||
@ -1,10 +1,15 @@
|
||||
{
|
||||
"name": "azure-core-tracing-opentelemetry-cpp",
|
||||
"version-string": "1.0.0-beta.1",
|
||||
"supports": "!(windows & !static)",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "azure-core-cpp",
|
||||
"default-features": false
|
||||
},
|
||||
{
|
||||
"name": "opentelemetry-cpp",
|
||||
"platform": "!uwp"
|
||||
"platform": "!(windows & !static)"
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
|
||||
@ -4,10 +4,11 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(azure-core-cpp "1.7.0-beta.1")
|
||||
find_dependency(Threads)
|
||||
|
||||
find_dependency(opentelemetry-cpp@CURL_MIN_REQUIRED_VERSION@)
|
||||
find_dependency(opentelemetry-cpp)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/azure-core-opentelemetry-cppTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/azure-core-tracing-opentelemetry-cppTargets.cmake")
|
||||
|
||||
check_required_components("azure-core-opentelemetry-cpp")
|
||||
check_required_components("azure-core-tracing-opentelemetry-cpp")
|
||||
|
||||
@ -4,14 +4,13 @@
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO Azure/azure-sdk-for-cpp
|
||||
REF azure-core_coretracing@AZ_LIBRARY_VERSION@
|
||||
REF azure-core-tracing-opentelemetry_@AZ_LIBRARY_VERSION@
|
||||
SHA512 0
|
||||
)
|
||||
|
||||
vcpkg_cmake_configure(
|
||||
SOURCE_PATH ${SOURCE_PATH}/sdk/core/azure-core/
|
||||
SOURCE_PATH ${SOURCE_PATH}/sdk/core/azure-core-tracing-opentelemetry/
|
||||
OPTIONS
|
||||
${FEATURE_OPTIONS}
|
||||
-DWARNINGS_AS_ERRORS=OFF
|
||||
)
|
||||
|
||||
|
||||
@ -2,15 +2,25 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
{
|
||||
"name": "azure-core-opentelemetry-cpp",
|
||||
"name": "azure-core-tracing-opentelemetry-cpp",
|
||||
"version-semver": "@AZ_LIBRARY_VERSION@",
|
||||
"description": [
|
||||
"Microsoft Azure Core OpenTelemetry SDK for C++",
|
||||
"Microsoft Azure Core Tracing OpenTelemetry SDK for C++",
|
||||
"This library provides support for modern Azure SDK client libraries written in C++ to leverage OpenTelemetry APIs."
|
||||
],
|
||||
"homepage": "https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/core/azure-core-opentelemetry",
|
||||
"homepage": "https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/core/azure-core-tracing-opentelemetry",
|
||||
"license": "MIT",
|
||||
"supports": "!(windows & !static)",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "azure-core-cpp",
|
||||
"default-features": false,
|
||||
"version>=": "1.7.0-beta.1"
|
||||
},
|
||||
{
|
||||
"name": "opentelemetry-cpp",
|
||||
"version>=": "1.3.0"
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"host": true
|
||||
@ -18,9 +28,6 @@
|
||||
{
|
||||
"name": "vcpkg-cmake-config",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "opentelemetry-cpp"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -46,6 +46,9 @@ stages:
|
||||
- Name: azure-core
|
||||
Path: azure-core
|
||||
VcpkgPortName: azure-core-cpp
|
||||
- Name: azure-core-tracing-opentelemetry
|
||||
Path: azure-core-tracing-opentelemetry
|
||||
VcpkgPortName: azure-core-tracing-opentelemetry-cpp
|
||||
# Since Azure Core will run all service's tests, it requires all the expected env vars from services
|
||||
TestEnv:
|
||||
# Key Vault
|
||||
|
||||
Loading…
Reference in New Issue
Block a user