diff --git a/cmake-modules/add_nlohmann_json.cmake b/cmake-modules/add_nlohmann_json.cmake deleted file mode 100644 index 56d632b168..0000000000 --- a/cmake-modules/add_nlohmann_json.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# SPDX-License-Identifier: MIT -# -# Azure Core can expose the Nlohmann Json header by fetching a release version and including the header to the include path. -# -# Azure Core will try to find the json header first. This is for an application that is already using Nlohmann header. -# When it is not found it, Azure Core will fetch it. - -# Storage requires 3.6.0 version for using `contains` feature -# Using QUIET to avoid warning message if lib is not found -find_package(nlohmann_json 3.6.0 EXACT QUIET) -if (NOT nlohmann_json_FOUND) - - include(FetchContent) - - # release code only. This save us from getting the entire nlohmann source code. - FetchContent_Declare(json - GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent - GIT_TAG v3.8.0) - - FetchContent_GetProperties(json) - if (NOT json_POPULATED) - FetchContent_Populate(json) - add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL) - endif() - -endif() diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 0471087960..f143d9a120 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -13,46 +13,46 @@ jobs: matrix: Linux_x64_gcc8: OSVmImage: 'ubuntu-18.04' - VcpkgInstall: 'curl[ssl] libxml2 openssl' + VcpkgInstall: 'curl[ssl] libxml2 openssl nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x64-linux' CC: '/usr/bin/gcc-8' CXX: '/usr/bin/g++-8' BuildArgs: '-j 10' Linux_x64_gcc9: OSVmImage: 'ubuntu-18.04' - VcpkgInstall: 'curl[ssl] libxml2 openssl' + VcpkgInstall: 'curl[ssl] libxml2 openssl nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x64-linux' CC: '/usr/bin/gcc-9' CXX: '/usr/bin/g++-9' BuildArgs: '-j 10' Linux_x64: OSVmImage: 'ubuntu-18.04' - VcpkgInstall: 'curl[ssl] libxml2 openssl' + VcpkgInstall: 'curl[ssl] libxml2 openssl nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x64-linux' BuildArgs: '-j 10' Win_x86: OSVmImage: 'windows-2019' - VcpkgInstall: 'curl[winssl] libxml2' + VcpkgInstall: 'curl[winssl] libxml2 nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x86-windows-static' CMAKE_GENERATOR: 'Visual Studio 16 2019' CMAKE_GENERATOR_PLATFORM: Win32 CmakeArgs: ' -DBUILD_TRANSPORT_CURL=ON' #ToBeRemoved once we have WinHttp Transport and Storage makes HTTP stack user-config Win_x64: OSVmImage: 'windows-2019' - VcpkgInstall: 'curl[winssl] libxml2' + VcpkgInstall: 'curl[winssl] libxml2 nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x64-windows-static' CMAKE_GENERATOR: 'Visual Studio 16 2019' CMAKE_GENERATOR_PLATFORM: x64 CmakeArgs: ' -DBUILD_TRANSPORT_CURL=ON' #ToBeRemoved once we have WinHttp Transport and Storage makes HTTP stack user-config MacOS_x64: OSVmImage: 'macOS-10.14' - VcpkgInstall: 'curl[ssl] libxml2 openssl' + VcpkgInstall: 'curl[ssl] libxml2 openssl nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x64-osx' # Unit testing ON Linux_x64_with_unit_test: OSVmImage: 'ubuntu-18.04' - VcpkgInstall: 'curl[ssl] libxml2 openssl' + VcpkgInstall: 'curl[ssl] libxml2 openssl nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x64-linux' CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_CODE_COVERAGE=ON' AptDependencies: 'gcovr lcov' @@ -62,21 +62,21 @@ jobs: BuildArgs: '-j 10' Win_x86_with_unit_test: OSVmImage: 'windows-2019' - VcpkgInstall: 'curl[winssl] libxml2' + VcpkgInstall: 'curl[winssl] libxml2 nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x86-windows-static' CMAKE_GENERATOR: 'Visual Studio 16 2019' CMAKE_GENERATOR_PLATFORM: Win32 CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON' Win_x64_with_unit_test: OSVmImage: 'windows-2019' - VcpkgInstall: 'curl[winssl] libxml2' + VcpkgInstall: 'curl[winssl] libxml2 nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x64-windows-static' CMAKE_GENERATOR: 'Visual Studio 16 2019' CMAKE_GENERATOR_PLATFORM: x64 CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON' MacOS_x64_with_unit_test: OSVmImage: 'macOS-10.14' - VcpkgInstall: 'curl[ssl] libxml2 openssl' + VcpkgInstall: 'curl[ssl] libxml2 openssl nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x64-osx' CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON' pool: @@ -139,7 +139,7 @@ jobs: vmImage: $(OSVmImage) variables: OSVmImage: windows-2019 - VcpkgDependencies: curl[winssl] libxml2 + VcpkgDependencies: curl[winssl] libxml2 nlohmann-json VCPKG_DEFAULT_TRIPLET: 'x64-windows-static' steps: - template: /eng/common/pipelines/templates/steps/verify-links.yml diff --git a/eng/pipelines/templates/jobs/archetype-sdk-tests.yml b/eng/pipelines/templates/jobs/archetype-sdk-tests.yml index 7e1ecb5bd4..91b1b28044 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-tests.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-tests.yml @@ -25,7 +25,7 @@ jobs: matrix: Linux_x64_with_unit_test: OSVmImage: 'ubuntu-18.04' - VcpkgInstall: 'curl[ssl] libxml2 openssl' + VcpkgInstall: 'curl[ssl] libxml2 openssl nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x64-linux' CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_CODE_COVERAGE=ON' AptDependencies: 'gcovr lcov' @@ -34,21 +34,21 @@ jobs: CODE_COVERAGE_COLLECT_ONLY: 1 Win_x86_with_unit_test: OSVmImage: 'windows-2019' - VcpkgInstall: 'curl[winssl] libxml2' + VcpkgInstall: 'curl[winssl] libxml2 nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x86-windows-static' CMAKE_GENERATOR: 'Visual Studio 16 2019' CMAKE_GENERATOR_PLATFORM: Win32 CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON' Win_x64_with_unit_test: OSVmImage: 'windows-2019' - VcpkgInstall: 'curl[winssl] libxml2' + VcpkgInstall: 'curl[winssl] libxml2 nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x64-windows-static' CMAKE_GENERATOR: 'Visual Studio 16 2019' CMAKE_GENERATOR_PLATFORM: x64 CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON' MacOS_x64_with_unit_test: OSVmImage: 'macOS-10.14' - VcpkgInstall: 'curl[ssl] libxml2 openssl' + VcpkgInstall: 'curl[ssl] libxml2 openssl nlohmann-json' VCPKG_DEFAULT_TRIPLET: 'x64-osx' CmakeArgs: ' -DBUILD_TESTING=ON -DRUN_LONG_UNIT_TESTS=ON' pool: diff --git a/sdk/core/azure-core/CMakeLists.txt b/sdk/core/azure-core/CMakeLists.txt index 5eac7c1cd6..94da91f5a2 100644 --- a/sdk/core/azure-core/CMakeLists.txt +++ b/sdk/core/azure-core/CMakeLists.txt @@ -21,6 +21,14 @@ if(NOT CURL_FOUND) endif() message("Libcurl version ${CURL_VERSION_STRING}") +# Storage requires 3.6.0 version for using `contains` feature +set(NLOHMANN_JSON_MIN_REQUIRED_VERSION 3.6.0) +find_package(nlohmann_json ${NLOHMANN_JSON_MIN_REQUIRED_VERSION} CONFIG) +if(NOT nlohmann_json_FOUND) + find_package(nlohmann_json ${NLOHMANN_JSON_MIN_REQUIRED_VERSION} REQUIRED) +endif() +message("nlohmann json version ${nlohmann_json_VERSION}") + if(BUILD_TRANSPORT_CURL) SET(CURL_TRANSPORT_ADAPTER_SRC src/http/curl/curl.cpp) endif() @@ -31,9 +39,6 @@ endif() # CodeCoverage will validate requirements include(CodeCoverage) -# nlohmann JSON -include(add_nlohmann_json) - add_library ( ${TARGET_NAME} src/context.cpp diff --git a/sdk/storage/azure-storage-files-shares/src/share_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_client.cpp index 6fc0ab1cf1..62a0a43db1 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_client.cpp @@ -129,7 +129,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const DeleteShareOptions& options) const { auto protocolLayerOptions = Details::ShareRestClient::Share::DeleteOptions(); - if (options.IncludeSnapshots.HasValue() and options.IncludeSnapshots.GetValue()) + if (options.IncludeSnapshots.HasValue() && options.IncludeSnapshots.GetValue()) { protocolLayerOptions.XMsDeleteSnapshots = Models::DeleteSnapshotsOptionType::Include; }