From 6c2e3628fa77b5f11b15e1c4a41e6b53a4e41002 Mon Sep 17 00:00:00 2001 From: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com> Date: Fri, 29 Sep 2023 12:16:53 -0700 Subject: [PATCH] Fix vcpkg features for azure-core-cpp (#4934) * Fix vcpkg features for azure-core-cpp * Rearrange conditions * EOL@EOF --------- Co-authored-by: Anton Kolesnyk --- cmake-modules/AzureTransportAdapters.cmake | 80 +++++++++++++--------- sdk/core/azure-core/vcpkg/portfile.cmake | 1 + 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/cmake-modules/AzureTransportAdapters.cmake b/cmake-modules/AzureTransportAdapters.cmake index bb29c622e..9bf0b16be 100644 --- a/cmake-modules/AzureTransportAdapters.cmake +++ b/cmake-modules/AzureTransportAdapters.cmake @@ -15,45 +15,57 @@ endif() # On Windows: Make sure to build WinHTTP either if it was user-requested or no transport was selected at all. # On POSIX: Make sure to build Curl either if it was user-requested or no transport was selected at all. -if (WIN32 OR MINGW OR MSYS OR CYGWIN) +if (NO_AUTOMATIC_TRANSPORT_BUILD) + message("Automatic transport build option detection is disabled.") + if (BUILD_TRANSPORT_CURL) - # Specified by user on CMake input Libcurl add_compile_definitions(BUILD_CURL_HTTP_TRANSPORT_ADAPTER) endif() - if (BUILD_TRANSPORT_WINHTTP OR (NOT BUILD_TRANSPORT_CURL AND NOT BUILD_TRANSPORT_CUSTOM)) - # WinHTTP selected by user on CMake input - # OR Nothing selected by CMake input (not libcurl or custom). Then set default for Windows. - - if (NOT BUILD_TRANSPORT_WINHTTP AND NOT BUILD_TRANSPORT_CUSTOM) - # No custom and No winHTTP. - message("No transport adapter was selected, using WinHTTP as the default option for Windows.") - endif() - - add_compile_definitions(BUILD_TRANSPORT_WINHTTP_ADAPTER) - - if (NOT BUILD_TRANSPORT_WINHTTP) - # When user did not provide the input option, we need to turn it ON as it is used to include the src code - SET(BUILD_TRANSPORT_WINHTTP ON) - endif() - endif() -elseif (UNIX) if (BUILD_TRANSPORT_WINHTTP) - message(FATAL_ERROR "WinHTTP transport adapter is not supported for POSIX platforms.") + add_compile_definitions(BUILD_TRANSPORT_WINHTTP_ADAPTER) endif() - - if (BUILD_TRANSPORT_CURL OR (NOT BUILD_TRANSPORT_CURL AND NOT BUILD_TRANSPORT_CUSTOM)) - - if(NOT BUILD_TRANSPORT_CURL) - message("No transport adapter was selected, using libcurl as the default option for POSIX.") - endif() - - add_compile_definitions(BUILD_CURL_HTTP_TRANSPORT_ADAPTER) - - - SET(BUILD_TRANSPORT_CURL ON) - endif() - else() - message(FATAL_ERROR "Unsupported platform.") + if (WIN32 OR MINGW OR MSYS OR CYGWIN) + if (BUILD_TRANSPORT_CURL) + # Specified by user on CMake input Libcurl + add_compile_definitions(BUILD_CURL_HTTP_TRANSPORT_ADAPTER) + endif() + if (BUILD_TRANSPORT_WINHTTP OR (NOT BUILD_TRANSPORT_CURL AND NOT BUILD_TRANSPORT_CUSTOM)) + # WinHTTP selected by user on CMake input + # OR Nothing selected by CMake input (not libcurl or custom). Then set default for Windows. + + if (NOT BUILD_TRANSPORT_WINHTTP AND NOT BUILD_TRANSPORT_CUSTOM) + # No custom and No winHTTP. + message("No transport adapter was selected, using WinHTTP as the default option for Windows.") + endif() + + add_compile_definitions(BUILD_TRANSPORT_WINHTTP_ADAPTER) + + if (NOT BUILD_TRANSPORT_WINHTTP) + # When user did not provide the input option, we need to turn it ON as it is used to include the src code + SET(BUILD_TRANSPORT_WINHTTP ON) + endif() + + endif() + elseif (UNIX) + if (BUILD_TRANSPORT_WINHTTP) + message(FATAL_ERROR "WinHTTP transport adapter is not supported for POSIX platforms.") + endif() + + if (BUILD_TRANSPORT_CURL OR (NOT BUILD_TRANSPORT_CURL AND NOT BUILD_TRANSPORT_CUSTOM)) + + if(NOT BUILD_TRANSPORT_CURL) + message("No transport adapter was selected, using libcurl as the default option for POSIX.") + endif() + + add_compile_definitions(BUILD_CURL_HTTP_TRANSPORT_ADAPTER) + + + SET(BUILD_TRANSPORT_CURL ON) + endif() + + else() + message(FATAL_ERROR "Unsupported platform.") + endif() endif() diff --git a/sdk/core/azure-core/vcpkg/portfile.cmake b/sdk/core/azure-core/vcpkg/portfile.cmake index 930636c18..87f3259fb 100644 --- a/sdk/core/azure-core/vcpkg/portfile.cmake +++ b/sdk/core/azure-core/vcpkg/portfile.cmake @@ -31,6 +31,7 @@ vcpkg_cmake_configure( ${FEATURE_OPTIONS} -DWARNINGS_AS_ERRORS=OFF -DBUILD_TESTING=OFF + -DNO_AUTOMATIC_TRANSPORT_BUILD=ON ) vcpkg_cmake_install()