Check for existence of BCrypt symbols before using BCrypt API.

This commit is contained in:
Nathan Moinvaziri 2023-04-24 10:33:12 -07:00
parent d160785a36
commit 75508d7f92

View File

@ -24,6 +24,7 @@ include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckSourceCompiles)
include(CheckTypeSize)
include(GNUInstallDirs)
include(FeatureSummary)
@ -435,17 +436,16 @@ if(WIN32)
if(MZ_OPENSSL)
list(APPEND MINIZIP_DEP_PKG OpenSSL)
else()
check_include_files("windows.h;bcrypt.h" BCRYPT_FOUND)
if (BCRYPT_FOUND)
message(STATUS "Using BCrypt")
# Check for existence of BCrypt API
set(CMAKE_REQUIRED_LIBRARIES bcrypt.lib ncrypt.lib crypt32.lib)
check_symbol_exists(BCryptGenRandom "windows.h;bcrypt.h" HAVE_BCRYPT)
set(CMAKE_REQUIRED_LIBRARIES)
if (HAVE_BCRYPT)
list(APPEND MINIZIP_SRC mz_crypt_winvista.c)
list(APPEND MINIZIP_LIB bcrypt.lib ncrypt.lib)
else()
message(STATUS "Using CryptoAPI")
list(APPEND MINIZIP_SRC mz_crypt_winxp.c)
endif()
list(APPEND MINIZIP_SRC mz_crypt_winxp.c)
list(APPEND MINIZIP_LIB crypt32.lib)
endif()
else()