From 73948b3ea607fe789ecd13119f0d5511dd9b6bfc Mon Sep 17 00:00:00 2001 From: Ewerton Scaboro da Silva Date: Tue, 16 May 2023 14:42:56 -0700 Subject: [PATCH] Fix library when using use_http=OFF (gh#622) --- CMakeLists.txt | 2 ++ adapters/platform_linux.c | 4 ++++ configs/azure_c_shared_utilityConfig.cmake | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 565b5ea1..de4e52aa 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,6 +276,8 @@ if(${use_http}) ./src/httpheaders.c ${HTTP_C_FILE} ) +else() + add_definitions(-DHTTP_DISABLED) endif() if(${use_schannel}) diff --git a/adapters/platform_linux.c b/adapters/platform_linux.c index 0724ff77..3612698d 100644 --- a/adapters/platform_linux.c +++ b/adapters/platform_linux.c @@ -31,11 +31,13 @@ int platform_init(void) { int result = 0; #ifndef DONT_USE_UPLOADTOBLOB +#if !defined(HTTP_DISABLED) if (HTTPAPIEX_Init() == HTTPAPIEX_ERROR) { LogError("HTTP for upload to blob failed on initialization."); result = MU_FAILURE; } +#endif /* HTTP_DISABLED */ #endif /* DONT_USE_UPLOADTOBLOB */ #ifdef USE_OPENSSL if (result == 0) @@ -92,7 +94,9 @@ STRING_HANDLE platform_get_platform_info(PLATFORM_INFO_OPTION options) void platform_deinit(void) { #ifndef DONT_USE_UPLOADTOBLOB +#if !defined(HTTP_DISABLED) HTTPAPIEX_Deinit(); +#endif /* HTTP_DISABLED */ #endif /* DONT_USE_UPLOADTOBLOB */ #ifdef USE_OPENSSL tlsio_openssl_deinit(); diff --git a/configs/azure_c_shared_utilityConfig.cmake b/configs/azure_c_shared_utilityConfig.cmake index 416dd1cc..2d7c733e 100644 --- a/configs/azure_c_shared_utilityConfig.cmake +++ b/configs/azure_c_shared_utilityConfig.cmake @@ -2,8 +2,10 @@ #Licensed under the MIT license. See LICENSE file in the project root for full license information. if(UNIX) - include(CMakeFindDependencyMacro) - find_dependency(CURL) + if(${use_http}) + include(CMakeFindDependencyMacro) + find_dependency(CURL) + endif() endif() include("${CMAKE_CURRENT_LIST_DIR}/azure_c_shared_utilityTargets.cmake")