diff --git a/CMakeLists.txt b/CMakeLists.txt index 401a6bfda..037f6c84a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,9 @@ cmake_minimum_required (VERSION 3.13) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules") +# Variable to indicate whether the entire SDK is being built, as opposed to an individual library. +set(AZ_ALL_LIBRARIES ON) + # Compile Options option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON) option(BUILD_TRANSPORT_CURL "Build an HTTP transport implementation with CURL" OFF) diff --git a/cmake-modules/AddGoogleTest.cmake b/cmake-modules/AddGoogleTest.cmake index 42b3e3f78..fea387ee3 100644 --- a/cmake-modules/AddGoogleTest.cmake +++ b/cmake-modules/AddGoogleTest.cmake @@ -67,7 +67,7 @@ endif() # Target must already exist macro(add_gtest TESTNAME) - target_link_libraries(${TESTNAME} PUBLIC gtest gmock gtest_main) + target_link_libraries(${TESTNAME} PRIVATE gtest gmock gtest_main) if(GOOGLE_TEST_INDIVIDUAL) if(CMAKE_VERSION VERSION_LESS 3.10) diff --git a/cmake-modules/az_vcpkg.cmake b/cmake-modules/az_vcpkg.cmake new file mode 100644 index 000000000..c2292c62d --- /dev/null +++ b/cmake-modules/az_vcpkg.cmake @@ -0,0 +1,85 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +# 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) + # VCPKG Integration + if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) + set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + CACHE STRING "") + elseif(DEFINED ENV{VCPKG_INSTALLATION_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) + set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" + CACHE STRING "") + endif() + if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) + set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") + endif() +endmacro() + +macro(az_vcpkg_export targetName) + # Produce the files to help with the VcPkg release. + # Go to the /out/build//vcpkg directory, and copy (merge) "ports" folder to the vcpkg repo. + # Then, update portfile.cmake's 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 ", and get the SHA from the error message). + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/CONTROL" "${CMAKE_BINARY_DIR}/vcpkg/ports/${targetName}-cpp/CONTROL" @ONLY) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/portfile.cmake" "${CMAKE_BINARY_DIR}/vcpkg/ports/${targetName}-cpp/portfile.cmake" @ONLY) + + # 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/" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + # 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 + ) + + # 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 version.hpp + COMPATIBILITY SameMajorVersion + ) + + # Install package cofig 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/ + ) + + # Export all the installs above as package. + export(PACKAGE "${targetName}-cpp") +endmacro() diff --git a/sdk/core/azure-core/CMakeLists.txt b/sdk/core/azure-core/CMakeLists.txt index 1a08d4f1c..b1c2148ec 100644 --- a/sdk/core/azure-core/CMakeLists.txt +++ b/sdk/core/azure-core/CMakeLists.txt @@ -10,12 +10,15 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake-modules") +include(az_vcpkg) include(az_version) include(CodeCoverage) include(DefineTransportAdapter) include(doxygen_common) include(global_compile_options) +az_vcpkg_integrate() + find_package(Threads REQUIRED) # min version for `CURLSSLOPT_NO_REVOKE` @@ -100,23 +103,26 @@ target_include_directories( azure-core PUBLIC $ - $ + $ ) # make sure that users can consume the project as a library. -add_library(Azure::Core ALIAS azure-core) +add_library(Azure::azure-core ALIAS azure-core) # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF -create_code_coverage(core azure-core "azure-core-test") +create_code_coverage(core azure-core azure-core-test) +# ${CURL_INCLUDE_DIRS} needs to be public as long as we #include in public headers. target_include_directories(azure-core PUBLIC ${CURL_INCLUDE_DIRS}) +target_include_directories(azure-core INTERFACE ${nlohmann_json_INCLUDE_DIRS}) +target_link_libraries(azure-core INTERFACE CURL::libcurl Threads::Threads nlohmann_json::nlohmann_json) if(BUILD_TRANSPORT_WINHTTP) SET(WIN_HTTP_LIB Winhttp.lib) + target_link_libraries(azure-core PRIVATE ${WIN_HTTP_LIB}) endif() -target_link_libraries(azure-core PRIVATE CURL::libcurl ${WIN_HTTP_LIB} Threads::Threads) -target_link_libraries(azure-core INTERFACE nlohmann_json::nlohmann_json) - get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/core/version.hpp") generate_documentation(azure-core ${AZ_LIBRARY_VERSION}) + +az_vcpkg_export(azure-core) diff --git a/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp b/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp index b33054c34..5ec274c76 100644 --- a/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp +++ b/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp @@ -9,6 +9,7 @@ #include #include +using Azure::Core::Context; using namespace Azure::Core::Http; namespace { diff --git a/sdk/core/azure-core/vcpkg/CONTROL b/sdk/core/azure-core/vcpkg/CONTROL new file mode 100644 index 000000000..b16c75aeb --- /dev/null +++ b/sdk/core/azure-core/vcpkg/CONTROL @@ -0,0 +1,15 @@ +Source: azure-core-cpp +Version: @AZ_LIBRARY_VERSION@ +Build-Depends: curl, nlohmann-json +Description: Microsoft Azure Core SDK for C++ + This library provides shared primitives, abstractions, and helpers for modern Azure SDK client libraries written in the C++. +Homepage: https://github.com/Azure/azure-sdk-for-cpp/tree/master/sdk/core/azure-core +Supports: !uwp +Default-Features: curl + +Feature: curl +Description: Build an HTTP transport implementation with LibCURL + +Feature: winhttp +Build-Depends: azure-core-cpp[core] (windows) +Description: Build an HTTP transport implementation with WinHTTP diff --git a/sdk/core/azure-core/vcpkg/Config.cmake.in b/sdk/core/azure-core/vcpkg/Config.cmake.in new file mode 100644 index 000000000..241b5c3aa --- /dev/null +++ b/sdk/core/azure-core/vcpkg/Config.cmake.in @@ -0,0 +1,15 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(Threads) +find_dependency(nlohmann_json @NLOHMANN_JSON_MIN_REQUIRED_VERSION@) +if(@BUILD_TRANSPORT_CURL@) + find_dependency(CURL @CURL_MIN_REQUIRED_VERSION@) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/azure-core-cppTargets.cmake") + +check_required_components("azure-core-cpp") diff --git a/sdk/core/azure-core/vcpkg/portfile.cmake b/sdk/core/azure-core/vcpkg/portfile.cmake new file mode 100644 index 000000000..5a3e94242 --- /dev/null +++ b/sdk/core/azure-core/vcpkg/portfile.cmake @@ -0,0 +1,32 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +vcpkg_fail_port_install(ON_TARGET "UWP") + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Azure/azure-sdk-for-cpp + REF azure-core_@AZ_LIBRARY_VERSION@ + SHA512 1 +) + +vcpkg_check_features( + OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + curl BUILD_TRANSPORT_CURL + winhttp BUILD_TRANSPORT_WINHTTP +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH}/sdk/core/azure-core/ + PREFER_NINJA + OPTIONS + ${FEATURE_OPTIONS} + -DWARNINGS_AS_ERRORS=OFF +) + +vcpkg_install_cmake() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +vcpkg_fixup_cmake_targets() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +vcpkg_copy_pdbs() diff --git a/sdk/identity/azure-identity/CMakeLists.txt b/sdk/identity/azure-identity/CMakeLists.txt index 63c1585de..fac679cd9 100644 --- a/sdk/identity/azure-identity/CMakeLists.txt +++ b/sdk/identity/azure-identity/CMakeLists.txt @@ -10,12 +10,22 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake-modules") +include(az_vcpkg) include(az_version) include(CodeCoverage) include(DefineTransportAdapter) include(doxygen_common) include(global_compile_options) +az_vcpkg_integrate() + +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() + set( AZURE_IDENTITY_HEADER inc/azure/identity/client_secret_credential.hpp @@ -34,15 +44,23 @@ set( add_library(azure-identity ${AZURE_IDENTITY_HEADER} ${AZURE_IDENTITY_SOURCE}) # make sure that users can consume the project as a library. -add_library(azure::identity ALIAS azure-identity) +add_library(Azure::azure-identity ALIAS azure-identity) # Uncomment once identity have tests # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF # create_code_coverage(identity azure-identity azure-identity-test) -target_include_directories(azure-identity PUBLIC inc) +target_include_directories( + azure-identity + PUBLIC + $ + $ + ${azure-core-cpp_INCLUDE_DIRS} +) -target_link_libraries(azure-identity PUBLIC azure-core) +target_link_libraries(azure-identity PUBLIC Azure::azure-core) get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/identity/version.hpp") generate_documentation(azure-identity ${AZ_LIBRARY_VERSION}) + +az_vcpkg_export(azure-identity) diff --git a/sdk/identity/azure-identity/vcpkg/CONTROL b/sdk/identity/azure-identity/vcpkg/CONTROL new file mode 100644 index 000000000..55629f87d --- /dev/null +++ b/sdk/identity/azure-identity/vcpkg/CONTROL @@ -0,0 +1,7 @@ +Source: azure-identity-cpp +Version: @AZ_LIBRARY_VERSION@ +Build-Depends: azure-core-cpp +Description: Microsoft Azure Identity SDK for C++ + This library provides common authentication-related abstractions for Azure SDK. +Homepage: https://github.com/Azure/azure-sdk-for-cpp/tree/master/sdk/identity/azure-identity +Supports: !uwp diff --git a/sdk/identity/azure-identity/vcpkg/Config.cmake.in b/sdk/identity/azure-identity/vcpkg/Config.cmake.in new file mode 100644 index 000000000..3ec0c675d --- /dev/null +++ b/sdk/identity/azure-identity/vcpkg/Config.cmake.in @@ -0,0 +1,11 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(azure-core-cpp) + +include("${CMAKE_CURRENT_LIST_DIR}/azure-identity-cppTargets.cmake") + +check_required_components("azure-identity-cpp") diff --git a/sdk/identity/azure-identity/vcpkg/portfile.cmake b/sdk/identity/azure-identity/vcpkg/portfile.cmake new file mode 100644 index 000000000..711d8dcfe --- /dev/null +++ b/sdk/identity/azure-identity/vcpkg/portfile.cmake @@ -0,0 +1,24 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +vcpkg_fail_port_install(ON_TARGET "UWP") + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Azure/azure-sdk-for-cpp + REF azure-identity_@AZ_LIBRARY_VERSION@ + SHA512 1 +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH}/sdk/identity/azure-identity/ + PREFER_NINJA + OPTIONS + -DWARNINGS_AS_ERRORS=OFF +) + +vcpkg_install_cmake() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +vcpkg_fixup_cmake_targets() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +vcpkg_copy_pdbs() diff --git a/sdk/storage/azure-storage-blobs/CMakeLists.txt b/sdk/storage/azure-storage-blobs/CMakeLists.txt index fd55e51ae..e55e31ddf 100644 --- a/sdk/storage/azure-storage-blobs/CMakeLists.txt +++ b/sdk/storage/azure-storage-blobs/CMakeLists.txt @@ -10,12 +10,22 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake-modules") +include(az_vcpkg) include(az_version) include(CodeCoverage) include(DefineTransportAdapter) include(doxygen_common) include(global_compile_options) +az_vcpkg_integrate() + +if(NOT AZ_ALL_LIBRARIES) + find_package(azure-storage-common-cpp CONFIG QUIET) + if(NOT azure-storage-common-cpp_FOUND) + find_package(azure-storage-common-cpp REQUIRED) + endif() +endif() + set( AZURE_STORAGE_BLOB_HEADER inc/azure/storage/blobs/protocol/blob_rest_client.hpp @@ -48,14 +58,23 @@ set( add_library(azure-storage-blobs ${AZURE_STORAGE_BLOB_HEADER} ${AZURE_STORAGE_BLOB_SOURCE}) # make sure that users can consume the project as a library. -add_library(azure::storage::blobs ALIAS azure-storage-blobs) +add_library(Azure::azure-storage-blobs ALIAS azure-storage-blobs) -target_include_directories(azure-storage-blobs PUBLIC inc) -target_link_libraries(azure-storage-blobs azure::storage::common) +target_include_directories( + azure-storage-blobs + PUBLIC + $ + $ + ${azure-storage-common-cpp_INCLUDE_DIRS} +) + +target_link_libraries(azure-storage-blobs PUBLIC Azure::azure-storage-common) get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/blobs/version.hpp") generate_documentation(azure-storage-blobs ${AZ_LIBRARY_VERSION}) +az_vcpkg_export(azure-storage-blobs) + # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF create_code_coverage(storage azure-storage-blobs azure-storage-test) diff --git a/sdk/storage/azure-storage-blobs/vcpkg/CONTROL b/sdk/storage/azure-storage-blobs/vcpkg/CONTROL new file mode 100644 index 000000000..0ca37f76f --- /dev/null +++ b/sdk/storage/azure-storage-blobs/vcpkg/CONTROL @@ -0,0 +1,7 @@ +Source: azure-storage-blobs-cpp +Version: @AZ_LIBRARY_VERSION@ +Build-Depends: azure-storage-common-cpp +Description: Microsoft Azure Storage Blobs SDK for C++ + This library provides Azure Storage Blobs SDK. +Homepage: https://github.com/Azure/azure-sdk-for-cpp/tree/master/sdk/storage/azure-storage-blobs +Supports: !uwp diff --git a/sdk/storage/azure-storage-blobs/vcpkg/Config.cmake.in b/sdk/storage/azure-storage-blobs/vcpkg/Config.cmake.in new file mode 100644 index 000000000..80fb4074f --- /dev/null +++ b/sdk/storage/azure-storage-blobs/vcpkg/Config.cmake.in @@ -0,0 +1,11 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(azure-storage-common-cpp) + +include("${CMAKE_CURRENT_LIST_DIR}/azure-storage-blobs-cppTargets.cmake") + +check_required_components("azure-storage-blobs-cpp") diff --git a/sdk/storage/azure-storage-blobs/vcpkg/portfile.cmake b/sdk/storage/azure-storage-blobs/vcpkg/portfile.cmake new file mode 100644 index 000000000..cb877393f --- /dev/null +++ b/sdk/storage/azure-storage-blobs/vcpkg/portfile.cmake @@ -0,0 +1,24 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +vcpkg_fail_port_install(ON_TARGET "UWP") + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Azure/azure-sdk-for-cpp + REF azure-storage-blobs_@AZ_LIBRARY_VERSION@ + SHA512 1 +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH}/sdk/storage/azure-storage-blobs/ + PREFER_NINJA + OPTIONS + -DWARNINGS_AS_ERRORS=OFF +) + +vcpkg_install_cmake() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +vcpkg_fixup_cmake_targets() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +vcpkg_copy_pdbs() diff --git a/sdk/storage/azure-storage-common/CMakeLists.txt b/sdk/storage/azure-storage-common/CMakeLists.txt index 88195da3e..24c0584e7 100644 --- a/sdk/storage/azure-storage-common/CMakeLists.txt +++ b/sdk/storage/azure-storage-common/CMakeLists.txt @@ -10,12 +10,22 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake-modules") +include(az_vcpkg) include(az_version) include(CodeCoverage) include(DefineTransportAdapter) include(doxygen_common) include(global_compile_options) +az_vcpkg_integrate() + +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(Threads REQUIRED) find_package(LibXml2 REQUIRED) @@ -56,22 +66,34 @@ set( add_library(azure-storage-common ${AZURE_STORAGE_COMMON_HEADER} ${AZURE_STORAGE_COMMON_SOURCE}) # make sure that users can consume the project as a library. -add_library(azure::storage::common ALIAS azure-storage-common) +add_library(Azure::azure-storage-common ALIAS azure-storage-common) + +target_include_directories( + azure-storage-common + PUBLIC + $ + $ + ${azure-core-cpp_INCLUDE_DIRS} +) + +target_include_directories(azure-storage-common INTERFACE ${LIBXML2_INCLUDE_DIRS}) +target_link_libraries(azure-storage-common PUBLIC Azure::azure-core) +target_link_libraries(azure-storage-common INTERFACE Threads::Threads ${LIBXML2_LIBRARIES}) -target_include_directories(azure-storage-common PUBLIC inc ${LIBXML2_INCLUDE_DIRS}) -target_link_libraries(azure-storage-common Threads::Threads azure-core ${LIBXML2_LIBRARIES}) if(MSVC) - target_link_libraries(azure-storage-common bcrypt) + target_link_libraries(azure-storage-common INTERFACE bcrypt) # C28020 and C28204 are introduced by nlohmann/json target_compile_options(azure-storage-common PUBLIC /wd28204 /wd28020) else() find_package(OpenSSL REQUIRED) - target_link_libraries(azure-storage-common OpenSSL::SSL OpenSSL::Crypto) + target_link_libraries(azure-storage-common INTERFACE OpenSSL::SSL OpenSSL::Crypto) endif() get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/common/version.hpp") generate_documentation(azure-storage-common ${AZ_LIBRARY_VERSION}) +az_vcpkg_export(azure-storage-common) + # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF # excluding json from coverage report create_code_coverage(storage azure-storage-common azure-storage-test "inc/azure/storage/common/json*") diff --git a/sdk/storage/azure-storage-common/vcpkg/CONTROL b/sdk/storage/azure-storage-common/vcpkg/CONTROL new file mode 100644 index 000000000..a05ba8e33 --- /dev/null +++ b/sdk/storage/azure-storage-common/vcpkg/CONTROL @@ -0,0 +1,7 @@ +Source: azure-storage-common-cpp +Version: @AZ_LIBRARY_VERSION@ +Build-Depends: azure-core-cpp, libxml2, openssl (!windows) +Description: Microsoft Azure Common Storage SDK for C++ + This library provides common Azure Storage-related abstractions for Azure SDK. +Homepage: https://github.com/Azure/azure-sdk-for-cpp/tree/master/sdk/storage/azure-storage-common +Supports: !uwp diff --git a/sdk/storage/azure-storage-common/vcpkg/Config.cmake.in b/sdk/storage/azure-storage-common/vcpkg/Config.cmake.in new file mode 100644 index 000000000..40f075b59 --- /dev/null +++ b/sdk/storage/azure-storage-common/vcpkg/Config.cmake.in @@ -0,0 +1,17 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(LibXml2) +find_dependency(Threads) +find_dependency(azure-core-cpp) + +if(NOT MSVC) + find_dependency(OpenSSL) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/azure-storage-common-cppTargets.cmake") + +check_required_components("azure-storage-common-cpp") diff --git a/sdk/storage/azure-storage-common/vcpkg/portfile.cmake b/sdk/storage/azure-storage-common/vcpkg/portfile.cmake new file mode 100644 index 000000000..15e90f910 --- /dev/null +++ b/sdk/storage/azure-storage-common/vcpkg/portfile.cmake @@ -0,0 +1,24 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +vcpkg_fail_port_install(ON_TARGET "UWP") + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Azure/azure-sdk-for-cpp + REF azure-storage-common_@AZ_LIBRARY_VERSION@ + SHA512 1 +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH}/sdk/storage/azure-storage-common/ + PREFER_NINJA + OPTIONS + -DWARNINGS_AS_ERRORS=OFF +) + +vcpkg_install_cmake() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +vcpkg_fixup_cmake_targets() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +vcpkg_copy_pdbs() diff --git a/sdk/storage/azure-storage-files-datalake/CMakeLists.txt b/sdk/storage/azure-storage-files-datalake/CMakeLists.txt index c50c122ad..13eca8743 100644 --- a/sdk/storage/azure-storage-files-datalake/CMakeLists.txt +++ b/sdk/storage/azure-storage-files-datalake/CMakeLists.txt @@ -10,12 +10,22 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake-modules") +include(az_vcpkg) include(az_version) include(CodeCoverage) include(DefineTransportAdapter) include(doxygen_common) include(global_compile_options) +az_vcpkg_integrate() + +if(NOT AZ_ALL_LIBRARIES) + find_package(azure-storage-blobs-cpp CONFIG QUIET) + if(NOT azure-storage-blobs-cpp_FOUND) + find_package(azure-storage-blobs-cpp REQUIRED) + endif() +endif() + set( AZURE_STORAGE_FILES_DATALAKE_HEADER inc/azure/storage/files/datalake/protocol/datalake_rest_client.hpp @@ -47,15 +57,23 @@ set( add_library(azure-storage-files-datalake ${AZURE_STORAGE_FILES_DATALAKE_HEADER} ${AZURE_STORAGE_FILES_DATALAKE_SOURCE}) # make sure that users can consume the project as a library. -add_library(azure::storage::files::datalake ALIAS azure-storage-files-datalake) +add_library(Azure::azure-storage-files-datalake ALIAS azure-storage-files-datalake) -target_include_directories(azure-storage-files-datalake PUBLIC inc) +target_include_directories( + azure-storage-files-datalake + PUBLIC + $ + $ + ${azure-storage-blobs-cpp_INCLUDE_DIRS} +) -target_link_libraries(azure-storage-files-datalake azure-storage-blobs) +target_link_libraries(azure-storage-files-datalake PUBLIC Azure::azure-storage-blobs) get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/files/datalake/version.hpp") generate_documentation(azure-storage-files-datalake ${AZ_LIBRARY_VERSION}) +az_vcpkg_export(azure-storage-files-datalake) + # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF create_code_coverage(storage azure-storage-files-datalake azure-storage-test) diff --git a/sdk/storage/azure-storage-files-datalake/vcpkg/CONTROL b/sdk/storage/azure-storage-files-datalake/vcpkg/CONTROL new file mode 100644 index 000000000..a67b05af9 --- /dev/null +++ b/sdk/storage/azure-storage-files-datalake/vcpkg/CONTROL @@ -0,0 +1,7 @@ +Source: azure-storage-files-datalake-cpp +Version: @AZ_LIBRARY_VERSION@ +Build-Depends: azure-storage-blobs-cpp +Description: Microsoft Azure Storage Files Data Lake SDK for C++ + This library provides Azure Storage Files Data Lake SDK. +Homepage: https://github.com/Azure/azure-sdk-for-cpp/tree/master/sdk/storage/azure-storage-files-datalake +Supports: !uwp diff --git a/sdk/storage/azure-storage-files-datalake/vcpkg/Config.cmake.in b/sdk/storage/azure-storage-files-datalake/vcpkg/Config.cmake.in new file mode 100644 index 000000000..72b67320f --- /dev/null +++ b/sdk/storage/azure-storage-files-datalake/vcpkg/Config.cmake.in @@ -0,0 +1,11 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(azure-storage-blobs-cpp) + +include("${CMAKE_CURRENT_LIST_DIR}/azure-storage-files-datalake-cppTargets.cmake") + +check_required_components("azure-storage-files-datalake-cpp") diff --git a/sdk/storage/azure-storage-files-datalake/vcpkg/portfile.cmake b/sdk/storage/azure-storage-files-datalake/vcpkg/portfile.cmake new file mode 100644 index 000000000..d69566bc8 --- /dev/null +++ b/sdk/storage/azure-storage-files-datalake/vcpkg/portfile.cmake @@ -0,0 +1,24 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +vcpkg_fail_port_install(ON_TARGET "UWP") + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Azure/azure-sdk-for-cpp + REF azure-storage-files-datalake_@AZ_LIBRARY_VERSION@ + SHA512 1 +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH}/sdk/storage/azure-storage-files-datalake/ + PREFER_NINJA + OPTIONS + -DWARNINGS_AS_ERRORS=OFF +) + +vcpkg_install_cmake() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +vcpkg_fixup_cmake_targets() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +vcpkg_copy_pdbs() diff --git a/sdk/storage/azure-storage-files-shares/CMakeLists.txt b/sdk/storage/azure-storage-files-shares/CMakeLists.txt index fe9d8f15a..cf10535d1 100644 --- a/sdk/storage/azure-storage-files-shares/CMakeLists.txt +++ b/sdk/storage/azure-storage-files-shares/CMakeLists.txt @@ -10,12 +10,22 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake-modules") +include(az_vcpkg) include(az_version) include(CodeCoverage) include(DefineTransportAdapter) include(doxygen_common) include(global_compile_options) +az_vcpkg_integrate() + +if(NOT AZ_ALL_LIBRARIES) + find_package(azure-storage-common-cpp CONFIG QUIET) + if(NOT azure-storage-common-cpp_FOUND) + find_package(azure-storage-common-cpp REQUIRED) + endif() +endif() + set( AZURE_STORAGE_FILES_SHARES_HEADER inc/azure/storage/files/shares/protocol/share_rest_client.hpp @@ -44,15 +54,23 @@ set( add_library(azure-storage-files-shares ${AZURE_STORAGE_FILES_SHARES_HEADER} ${AZURE_STORAGE_FILES_SHARES_SOURCE}) # make sure that users can consume the project as a library. -add_library(azure::storage::files::shares ALIAS azure-storage-files-shares) +add_library(Azure::azure-storage-files-shares ALIAS azure-storage-files-shares) -target_include_directories(azure-storage-files-shares PUBLIC inc) +target_include_directories( + azure-storage-files-shares + PUBLIC + $ + $ + ${azure-storage-common-cpp_INCLUDE_DIRS} +) -target_link_libraries(azure-storage-files-shares azure-storage-common) +target_link_libraries(azure-storage-files-shares PUBLIC Azure::azure-storage-common) get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/files/shares/version.hpp") generate_documentation(azure-storage-files-shares ${AZ_LIBRARY_VERSION}) +az_vcpkg_export(azure-storage-files-shares) + # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF create_code_coverage(storage azure-storage-files-shares azure-storage-test) diff --git a/sdk/storage/azure-storage-files-shares/vcpkg/CONTROL b/sdk/storage/azure-storage-files-shares/vcpkg/CONTROL new file mode 100644 index 000000000..2e5dbff89 --- /dev/null +++ b/sdk/storage/azure-storage-files-shares/vcpkg/CONTROL @@ -0,0 +1,7 @@ +Source: azure-storage-files-shares-cpp +Version: @AZ_LIBRARY_VERSION@ +Build-Depends: azure-storage-common-cpp +Description: Microsoft Azure Storage Files Shares SDK for C++ + This library provides Azure Storage Files Shares SDK. +Homepage: https://github.com/Azure/azure-sdk-for-cpp/tree/master/sdk/storage/azure-storage-files-shares +Supports: !uwp diff --git a/sdk/storage/azure-storage-files-shares/vcpkg/Config.cmake.in b/sdk/storage/azure-storage-files-shares/vcpkg/Config.cmake.in new file mode 100644 index 000000000..4dab59afd --- /dev/null +++ b/sdk/storage/azure-storage-files-shares/vcpkg/Config.cmake.in @@ -0,0 +1,11 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(azure-storage-common-cpp) + +include("${CMAKE_CURRENT_LIST_DIR}/azure-storage-files-shares-cppTargets.cmake") + +check_required_components("azure-storage-files-shares-cpp") diff --git a/sdk/storage/azure-storage-files-shares/vcpkg/portfile.cmake b/sdk/storage/azure-storage-files-shares/vcpkg/portfile.cmake new file mode 100644 index 000000000..23277a671 --- /dev/null +++ b/sdk/storage/azure-storage-files-shares/vcpkg/portfile.cmake @@ -0,0 +1,24 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +vcpkg_fail_port_install(ON_TARGET "UWP") + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Azure/azure-sdk-for-cpp + REF azure-storage-files-shares_@AZ_LIBRARY_VERSION@ + SHA512 1 +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH}/sdk/storage/azure-storage-files-shares/ + PREFER_NINJA + OPTIONS + -DWARNINGS_AS_ERRORS=OFF +) + +vcpkg_install_cmake() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +vcpkg_fixup_cmake_targets() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +vcpkg_copy_pdbs() diff --git a/sdk/template/azure-template/CMakeLists.txt b/sdk/template/azure-template/CMakeLists.txt index 06498f658..12618600e 100644 --- a/sdk/template/azure-template/CMakeLists.txt +++ b/sdk/template/azure-template/CMakeLists.txt @@ -10,12 +10,22 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake-modules") +include(az_vcpkg) include(az_version) include(CodeCoverage) include(DefineTransportAdapter) include(doxygen_common) include(global_compile_options) +az_vcpkg_integrate() + +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() + set( AZURE_TEMPLATE_HEADER inc/azure/template/template_client.hpp @@ -31,11 +41,18 @@ set( add_library(azure-template ${AZURE_TEMPLATE_HEADER} ${AZURE_TEMPLATE_SOURCE}) -target_include_directories(azure-template PUBLIC inc) -target_link_libraries(azure-identity PUBLIC azure-core) +target_include_directories( + azure-template + PUBLIC + $ + $ + ${azure-core-cpp_INCLUDE_DIRS} +) + +target_link_libraries(azure-template PUBLIC Azure::azure-core) # make sure that users can consume the project as a library. -add_library(Azure::Template ALIAS azure-template) +add_library(Azure::azure-template ALIAS azure-template) # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF create_code_coverage(template azure-template azure-template-test) @@ -43,6 +60,8 @@ create_code_coverage(template azure-template azure-template-test) get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/template/version.hpp") generate_documentation(azure-template ${AZ_LIBRARY_VERSION}) +az_vcpkg_export(azure-template) + if(BUILD_TESTING) # tests add_subdirectory(test) diff --git a/sdk/template/azure-template/test/CMakeLists.txt b/sdk/template/azure-template/test/CMakeLists.txt index ea0e76eba..b52cf7d55 100644 --- a/sdk/template/azure-template/test/CMakeLists.txt +++ b/sdk/template/azure-template/test/CMakeLists.txt @@ -14,7 +14,7 @@ add_executable ( ut/template_test.cpp ) -target_link_libraries(azure-template-test PUBLIC Azure::Template) +target_link_libraries(azure-template-test PRIVATE Azure::azure-template) if (MSVC) target_compile_options(azure-template-test PUBLIC /wd6326 /wd26495 /wd26812) diff --git a/sdk/template/azure-template/vcpkg/CONTROL b/sdk/template/azure-template/vcpkg/CONTROL new file mode 100644 index 000000000..02362f237 --- /dev/null +++ b/sdk/template/azure-template/vcpkg/CONTROL @@ -0,0 +1,8 @@ +Source: azure-template-cpp +Version: @AZ_LIBRARY_VERSION@ +Build-Depends: azure-core-cpp +Description: Microsoft Azure Template SDK for C++ + This is a template library meant to illustrate initial client library development process for Azure SDK. + It is not meant to be published to vcpkg. +Homepage: https://github.com/Azure/azure-sdk-for-cpp/tree/master/sdk/template/azure-template +Supports: !uwp diff --git a/sdk/template/azure-template/vcpkg/Config.cmake.in b/sdk/template/azure-template/vcpkg/Config.cmake.in new file mode 100644 index 000000000..bed4af3e9 --- /dev/null +++ b/sdk/template/azure-template/vcpkg/Config.cmake.in @@ -0,0 +1,11 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(azure-core-cpp) + +include("${CMAKE_CURRENT_LIST_DIR}/azure-template-cppTargets.cmake") + +check_required_components("azure-template-cpp") diff --git a/sdk/template/azure-template/vcpkg/portfile.cmake b/sdk/template/azure-template/vcpkg/portfile.cmake new file mode 100644 index 000000000..f2cbf566e --- /dev/null +++ b/sdk/template/azure-template/vcpkg/portfile.cmake @@ -0,0 +1,24 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: MIT + +vcpkg_fail_port_install(ON_TARGET "UWP") + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Azure/azure-sdk-for-cpp + REF azure-template_@AZ_LIBRARY_VERSION@ + SHA512 1 +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH}/sdk/template/azure-template/ + PREFER_NINJA + OPTIONS + -DWARNINGS_AS_ERRORS=OFF +) + +vcpkg_install_cmake() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +vcpkg_fixup_cmake_targets() +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +vcpkg_copy_pdbs()