azure-sdk-for-cpp/cmake-modules/AzureVcpkg.cmake
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

172 lines
7.0 KiB
CMake

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# We need to know an absolute path to our repo root to do things like referencing ./LICENSE.txt file.
set(AZ_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/..")
macro(az_vcpkg_integrate)
message("Vcpkg integrate step.")
# AUTO CMAKE_TOOLCHAIN_FILE:
# User can call `cmake -DCMAKE_TOOLCHAIN_FILE="path_to_the_toolchain"` as the most specific scenario.
# As the last alternative (default case), Azure SDK will automatically clone VCPKG folder and set toolchain from there.
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
message("CMAKE_TOOLCHAIN_FILE is not defined. Define it for the user.")
# Set AZURE_SDK_DISABLE_AUTO_VCPKG env var to avoid Azure SDK from cloning and setting VCPKG automatically
# This option delegate package's dependencies installation to user.
if(NOT DEFINED ENV{AZURE_SDK_DISABLE_AUTO_VCPKG})
message("AZURE_SDK_DISABLE_AUTO_VCPKG is not defined. Fetch a local copy of vcpkg.")
# GET VCPKG FROM SOURCE
# User can set env var AZURE_SDK_VCPKG_COMMIT to pick the VCPKG commit to fetch
set(VCPKG_COMMIT_STRING f0f811770e0538fcb295a1750c0a5e0de5131d29) # default SDK tested commit
if(DEFINED ENV{AZURE_SDK_VCPKG_COMMIT})
message("AZURE_SDK_VCPKG_COMMIT is defined. Using that instead of the default.")
set(VCPKG_COMMIT_STRING "$ENV{AZURE_SDK_VCPKG_COMMIT}") # default SDK tested commit
endif()
message("Vcpkg commit string used: ${VCPKG_COMMIT_STRING}")
include(FetchContent)
FetchContent_Declare(
vcpkg
GIT_REPOSITORY https://github.com/microsoft/vcpkg.git
GIT_TAG ${VCPKG_COMMIT_STRING}
)
FetchContent_GetProperties(vcpkg)
# make sure to pull vcpkg only once.
if(NOT vcpkg_POPULATED)
FetchContent_MakeAvailable(vcpkg)
endif()
# use the vcpkg source path
set(CMAKE_TOOLCHAIN_FILE "${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
endif()
endif()
# enable triplet customization
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
endif()
message("Vcpkg integrate step - DONE.")
endmacro()
macro(az_vcpkg_portfile_prep targetName fileName contentToRemove)
# with sdk/<lib>/vcpkg/<fileName>
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/${fileName}" fileContents)
# Windows -> Unix line endings
string(FIND fileContents "\r\n" crLfPos)
if (crLfPos GREATER -1)
string(REPLACE "\r\n" "\n" fileContents ${fileContents})
endif()
# remove comment header
string(REPLACE "${contentToRemove}" "" fileContents ${fileContents})
# undo Windows -> Unix line endings (if applicable)
if (crLfPos GREATER -1)
string(REPLACE "\n" "\r\n" fileContents ${fileContents})
endif()
unset(crLfPos)
# output to an intermediate location
file (WRITE "${CMAKE_BINARY_DIR}/vcpkg_prep/${targetName}/${fileName}" ${fileContents})
unset(fileContents)
# Produce the files to help with the vcpkg release.
# Go to the /out/build/<cfg>/vcpkg directory, and copy (merge) "ports" folder to the vcpkg repo.
# Then, update the portfile.cmake file SHA512 from "1" to the actual hash (a good way to do it is to uninstall a package,
# clean vcpkg/downloads, vcpkg/buildtrees, run "vcpkg install <pkg>", and get the SHA from the error message).
configure_file(
"${CMAKE_BINARY_DIR}/vcpkg_prep/${targetName}/${fileName}"
"${CMAKE_BINARY_DIR}/vcpkg/ports/${targetName}-cpp/${fileName}"
@ONLY
)
endmacro()
macro(az_vcpkg_export targetName macroNamePart dllImportExportHeaderPath)
foreach(vcpkgFile "vcpkg.json" "portfile.cmake")
az_vcpkg_portfile_prep(
"${targetName}"
"${vcpkgFile}"
"# Copyright (c) Microsoft Corporation.\n# Licensed under the MIT License.\n\n"
)
endforeach()
# Standard names for folders such as "bin", "lib", "include". We could hardcode, but some other libs use it too (curl).
include(GNUInstallDirs)
# When installing, copy our "inc" directory (headers) to "include" directory at the install location.
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/azure")
# Copy license as "copyright" (vcpkg dictates naming and location).
install(FILES "${AZ_ROOT_DIR}/LICENSE.txt" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${targetName}-cpp" RENAME "copyright")
# Indicate where to install targets. Mirrors what other ports do.
install(
TARGETS "${targetName}"
EXPORT "${targetName}-cppTargets"
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # DLLs (if produced by build) go to "/bin"
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # static .lib files
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # .lib files for DLL build
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers
)
# If building a Windows DLL, patch the dll_import_export.hpp
if(WIN32 AND BUILD_SHARED_LIBS)
add_compile_definitions(AZ_${macroNamePart}_BEING_BUILT)
target_compile_definitions(${targetName} PUBLIC AZ_${macroNamePart}_DLL)
set(AZ_${macroNamePart}_DLL_INSTALLED_AS_PACKAGE "*/ + 1 /*")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/inc/${dllImportExportHeaderPath}"
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${dllImportExportHeaderPath}"
@ONLY
)
unset(AZ_${macroNamePart}_DLL_INSTALLED_AS_PACKAGE)
get_filename_component(dllImportExportHeaderDir ${dllImportExportHeaderPath} DIRECTORY)
install(
FILES "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${dllImportExportHeaderPath}"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${dllImportExportHeaderDir}"
)
unset(dllImportExportHeaderDir)
endif()
# Export the targets file itself.
install(
EXPORT "${targetName}-cppTargets"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${targetName}-cpp"
NAMESPACE Azure:: # Not the C++ namespace, but a namespace in terms of cmake.
FILE "${targetName}-cppTargets.cmake"
)
# configure_package_config_file(), write_basic_package_version_file()
include(CMakePackageConfigHelpers)
# Produce package config file.
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/Config.cmake.in"
"${targetName}-cppConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${targetName}-cpp"
PATH_VARS
CMAKE_INSTALL_LIBDIR)
# Produce version file.
write_basic_package_version_file(
"${targetName}-cppConfigVersion.cmake"
VERSION ${AZ_LIBRARY_VERSION} # the version that we extracted from package_version.hpp
COMPATIBILITY SameMajorVersion
)
# Install package config and version files.
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${targetName}-cppConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${targetName}-cppConfigVersion.cmake"
DESTINATION
"${CMAKE_INSTALL_DATAROOTDIR}/${targetName}-cpp" # to shares/<our_pkg>
)
# Export all the installs above as package.
export(PACKAGE "${targetName}-cpp")
endmacro()