azure-sdk-for-cpp/cmake-modules/DefineTransportAdapter.cmake
Victor Vazquez cd2a8a3812
cmake updates for building transport adapters (#706)
Adding CMake module to enable/disable transport adapters

TRANSPORT ADAPTER BUILD  
Default: If no option is explicitly added, curl will be used for POSIX and WIN HTTP for WIndows 
 Windows: Both CURL and WIN_HTTP can be build to be used.                                        
POSIX: Only CURL is acceptable. If WIN_HTTP is set, generate step will fail for user            

Defines `BUILD_WIN_HTTP_TRANSPORT_ADAPTER` and `BUILD_CURL_HTTP_TRANSPORT_ADAPTER` for source code
 
Fixes #350
2020-10-10 00:08:57 +00:00

30 lines
1.4 KiB
CMake

## Copyright (c) Microsoft Corporation. All rights reserved.
## SPDX-License-Identifier: MIT
############# TRANSPORT ADAPTER BUILD #####################
# Default: If no option is explicitly added, curl will be used for POSIX and WIN HTTP for Windows #
# Windows: Both CURL and WIN_HTTP can be built to be used. #
# POSIX: Only CURL is acceptable. If WIN_HTTP is set, generate step will fail for user #
# Defines `BUILD_TRANSPORT_WINHTTP_ADAPTER` and `BUILD_CURL_HTTP_TRANSPORT_ADAPTER` for source code
if (WIN32 OR MINGW OR MSYS OR CYGWIN)
if(BUILD_TRANSPORT_CURL)
add_compile_definitions(BUILD_CURL_HTTP_TRANSPORT_ADAPTER)
endif()
# Make sure to build WinHTTP either if was user-requested or no transport was selected at all
if(BUILD_TRANSPORT_WINHTTP OR NOT BUILD_TRANSPORT_CURL)
add_compile_definitions(BUILD_TRANSPORT_WINHTTP_ADAPTER)
SET(BUILD_TRANSPORT_WINHTTP ON)
endif()
elseif(UNIX)
if(BUILD_TRANSPORT_WINHTTP)
message(FATAL_ERROR "Win HTTP transport adapter is not supported for Unix platforms")
endif()
# regardless if CURL transport is set or not, it is always added for UNIX as default
add_compile_definitions(BUILD_CURL_HTTP_TRANSPORT_ADAPTER)
SET(BUILD_TRANSPORT_CURL ON)
else()
message(FATAL_ERROR "Unsupported platform")
endif ()