azure-sdk-for-cpp/CMakeLists.txt
Larry Osterman e04e96cf87
Merged Rust AMQP stack with main. (#6442)
* Initial attempt at a Rust AMQP stack, merged against feature/rust_amqp for now. (#5942)

* Enabled building AMQP *without* uAMQP

* Start integrating Rust AMQP Value to C++ AMQP Value

* AMQP Value tests now pass

* Moved AmqpValueType ostream inserter to its original location

* Added Rust AMQP Message implementation

* Added start of message source tests

* Enabled building AMQP *without* uAMQP

* Start integrating Rust AMQP Value to C++ AMQP Value

* Moved AmqpValueType ostream inserter to its original location

* Message target support

* Message source and target support

* Add connection support; restructured tests to fail on RUST AMQP rather than attempting to run; removed some uAMQP-only features  (#5986)

* Checkpoint of connection logic

* Started implementing Rust based Connection by pulling out uAMQP artifacts

* Implemented AMQP Connection in Rust; started API surface refactoring for Rust APIs; Refactored tests to remove some uAMQP only elements.

* Don't leak runtime context on calls

* Refactor AMQP logic to better isolate rust AMQP code from uAMQP code. (#6008)

* refactor uAMQP and Rust AMQP into separate implementations for ease of use

* Add connection support; restructured tests to fail on RUST AMQP rather than attempting to run; removed some uAMQP-only features  (#5986)

* Checkpoint of connection logic

* Started implementing Rust based Connection by pulling out uAMQP artifacts

* Implemented AMQP Connection in Rust; started API surface refactoring for Rust APIs; Refactored tests to remove some uAMQP only elements.

* Don't leak runtime context on calls

* export UUID from AMQP

* Cleaned up some more elements; reduced scope of doxygen significantly

* runtime context needs to be process global not thread global; all tests pass or fail at this point

* Merged main into branch

* Implement AMQP Session APIs in Rust. (#6033)

* Checkpoint of rust session support

* Session begin/end now works

* Session tests pass

* Removed accidental regression

* Added rust per-call context (#6043)

* Reworked runtime context to be call context

* Added context parameter to blocking AMQP calls

* Added comments around the lifetime of the RustRuntimeContext captured in the CallContext object

* uAMQP changes corresponding to Rust changes

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* sync rust SDK fixes to C++

---------

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Enable Rust ClaimsBasedSecurity interoperability; Converted EventHubs producer client to work with Rust AMQP changes. (#6059)

* canonicalized return values; initial CBS support

* Implementation of CBS for C++

* Amqp Authentication works; Integrate Rust AMQP into Eventhubs Producer client

* Implemented Rust AMQP message sender. (#6083)

* Initial sender implementation

* PR feedback

* Management APIs work (#6096)


* Management APIs work

---------

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Converted builders to be compliant with Rust guidelines. (#6102)

* Converted builders to be compliant with Rust guidelines.

* Bring rust changes back to C++ repo

* Improved builder developer experience

* Removed builders from AMQP layer to conform to Rust guidelines; Fixed AMQP bug in message sender tests (#6208)

* Removed builders from AMQP layer to conform to Rust guidelines; Fixed AMQP related bug in message sender tests

* Pr feedback

* Implement receiving messages; Changes to eventhubs so that all eventhubs tests pass (#6254)


* Eventhubs tests pass

* Noise reduction; explain the task which spawns a task

* Update sdk/eventhubs/azure-messaging-eventhubs/src/producer_client.cpp

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* PR feedback

---------

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Integrate Rust 2 step message receive code to C++ (#6349)

* Integrate Rust 2 step message receive code to C++

* If receiving a delivery failed, transmit the error to the message channel if at all possible

* Enable Rust based AMQP by default (#6362)

* AMQP tests now pass; Integrate TestAmqpBroker with CI pipeline

* Updated changelogs to reflect API changes made during AMQP updates

* Replace uAMQP with Rust AMQP as the default AMQP transport; Updated build configurationj to reflect that

* Test fixes

* PR feedback; test fixes

* Fixed uninitialized variable tanking some tests (#6381)

* Fixed uninitialized variable tanking some tests

* Fixed Rust AMQP tests

* Removed connection string support from Eventhubs and EH tests. (#6391)

* Removed the ability to use connection strings from EventHubs

* Enable Rust AMQP by default!!!

* Update CMakePresets.json

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

---------

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>
2025-03-11 22:30:13 +00:00

196 lines
7.5 KiB
CMake

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# cspell: words fsanitize
cmake_minimum_required (VERSION 3.13)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules")
# Disable Rust based APIs in C++ SDK.
set(DISABLE_RUST_IN_BUILD OFF CACHE BOOL "Disable Rust based APIs in package")
set(DISABLE_AMQP OFF CACHE BOOL "Disable AMQP based functionality")
set(DISABLE_AZURE_CORE_OPENTELEMETRY OFF CACHE BOOL "Disable OpenTelemetry based functionality")
# The Rust OpenSSL library conflicts with the vcpkg based OpenSSL library, which causes TLS operations to fail on Linux.
# For now, disabling rust functionality on Linux operating systems.
if(LINUX)
#set(DISABLE_RUST_IN_BUILD ON)
endif()
# Variable to indicate whether the entire SDK is being built, as opposed to an individual library.
set(AZ_ALL_LIBRARIES ON)
# Compile Options
include(FolderList)
SetGlobalOptions()
if(FETCH_SOURCE_DEPS)
message(FATAL_ERROR, "FETCH_SOURCE_DEPS flag not for global use, instead use when building individual components")
return()
endif()
include(AzureTransportAdapters)
include(AzureVcpkg)
include(AzureBuildTargetForCI)
az_vcpkg_integrate()
# Project definition
project(azure-sdk LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Enable a build configuration to disable features when building for Windows Store.
message(STATUS "CMAKE_SYSTEM_NAME=" ${CMAKE_SYSTEM_NAME} ";")
message(STATUS "VCPKG_TARGET_TRIPLET=" ${VCPKG_TARGET_TRIPLET} ";")
# In the CI pipeline, for <reasons>, CMAKE_SYSTEM_NAME is set to "Windows" even when building for Windows Store.
# use the CMAKE triplet to detect the windows store build.
if ((${VCPKG_TARGET_TRIPLET} MATCHES ".*-uwp"))
set(BUILD_WINDOWS_UWP True)
message(STATUS "Building for Windows Store, CMAKE_SYSTEM_NAME=" ${CMAKE_SYSTEM_NAME})
endif()
if (BUILD_WINDOWS_UWP)
if (DISABLE_RUST_IN_BUILD)
message(STATUS "uAMQP is incompatible with UWP builds.")
set(DISABLE_AMQP ON)
endif()
message(STATUS "opentelemetry-cpp package is incompatible with UWP builds.")
set(DISABLE_AZURE_CORE_OPENTELEMETRY ON)
endif()
# For MSVC, ensure that the compiler is operating in strict compliance mode.
if (MSVC)
# See also: https://learn.microsoft.com/cpp/build/reference/permissive-standards-conformance
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
endif()
if(MSVC_USE_STATIC_CRT AND MSVC)
# 1. More about static/shared CRT:
# https://learn.microsoft.com/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-160
#
# 2. MSVC_USE_STATIC_CRT build flag approach is used/inspired by libcurl
# (https://github.com/curl/curl/blob/master/CMakeLists.txt) and some other projects.
#
# 3. GTest would emit the following warning:
# warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
# AddGoogleTest.cmake uses gtest_force_shared_crt
# (see https://github.com/google/googletest/blob/master/googletest/README.md),
# which respects linker settings that we set below, and our settings below are all in sync.
#
# 4. Sometimes, the following approach is recommended instead:
# +-----------------------------------------------------------------------------------+
# | # Use the static runtime libraries when building statically |
# | # for consistency with the vcpkg arch-windows-static triplets: |
# | cmake_policy(SET CMP0091 NEW) |
# | # see https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html |
# | if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) |
# | set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") |
# | endif() |
# +-----------------------------------------------------------------------------------+
# However, it only works when cmake installed is 3.15+;
# we have to require a minimum of 3.13.
#
# 5. We "replace with empty string" (i.e. remove) first, then add, so that '/MT'
# will be present (and present once) even if '/MD' was not.
message(STATUS "Configuring Static Runtime Library.")
if(${CMAKE_CXX_FLAGS} MATCHES ".*/MD.*")
string(REGEX REPLACE "/MD" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
endif()
if(${CMAKE_CXX_FLAGS_RELEASE} MATCHES ".*/MD.*")
string(REGEX REPLACE "/MD" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
endif()
if(${CMAKE_CXX_FLAGS_RELWITHDEBINFO} MATCHES ".*/MD.*")
string(REGEX REPLACE "/MD" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
endif()
if(${CMAKE_CXX_FLAGS_MINSIZEREL} MATCHES ".*/MD.*")
string(REGEX REPLACE "/MD" "" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
endif()
if(${CMAKE_CXX_FLAGS_DEBUG} MATCHES ".*/MD.*")
string(REGEX REPLACE "/MDd" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif()
# Now make the same adjustments for .C files as was done for .CPP files.
if(${CMAKE_C_FLAGS} MATCHES ".*/MD.*")
string(REGEX REPLACE "/MD" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT")
endif()
if(${CMAKE_C_FLAGS_RELEASE} MATCHES ".*/MD.*")
string(REGEX REPLACE "/MD" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
endif()
if(${CMAKE_C_FLAGS_RELWITHDEBINFO} MATCHES ".*/MD.*")
string(REGEX REPLACE "/MD" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
endif()
if(${CMAKE_C_FLAGS_MINSIZEREL} MATCHES ".*/MD.*")
string(REGEX REPLACE "/MD" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
endif()
if(${CMAKE_C_FLAGS_DEBUG} MATCHES ".*/MD.*")
string(REGEX REPLACE "/MDd" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
endif()
endif()
# If the cmake presets enable Address Sanitizer, enable it for the project.
if (ENABLE_ADDRESS_SANITIZER)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()
if(BUILD_TESTING)
include(AddGoogleTest)
enable_testing ()
endif()
# compiler warning flags globally
include(AzureGlobalCompileOptions)
# Add create_map_file function
include(CreateMapFile)
# Documentation automation function
include(AzureDoxygen)
# Functions for library versions
include(AzureVersion)
if(BUILD_SAMPLES)
add_subdirectory(samples/helpers/get-env)
add_subdirectory(samples/helpers/service)
endif()
# sub-projects
add_subdirectory(sdk/core)
add_subdirectory(sdk/appconfiguration)
add_subdirectory(sdk/attestation)
# AMQP doesn't work for UWP yet, and eventhubs depends on AMQP, so we cannot include eventhubs on UWP.
if (NOT DISABLE_AMQP)
add_subdirectory(sdk/eventhubs)
endif()
add_subdirectory(sdk/identity)
add_subdirectory(sdk/keyvault)
add_subdirectory(sdk/storage)
add_subdirectory(sdk/template)
add_subdirectory(sdk/tables)
if(BUILD_SAMPLES)
add_subdirectory(samples/integration/vcpkg-all-smoke)
endif()