Skip to content

Commit

Permalink
improved test if bcrypt is available
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas authored and zpostfacto committed Sep 9, 2024
1 parent 6aa4e78 commit 5020374
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ if (WIN32)
#
# Check whether BCrypt can be used with this SDK version
#
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES bcrypt)
check_symbol_exists(BCryptEncrypt windows.h BCRYPT_AVAILABLE)
cmake_pop_check_state()
try_compile(BCRYPT_AVAILABLE "${CMAKE_CURRENT_BINARY_DIR}/tryCompile" SOURCES "${CMAKE_CURRENT_LIST_DIR}/cmake/tryCompileTestBCrypt.cpp" OUTPUT_VARIABLE BCRYPT_AVAILABILITY_TEST_MESSAGES)
if (NOT BCRYPT_AVAILABLE)
message(STATUS ${BCRYPT_AVAILABILITY_TEST_MESSAGES})
message(FATAL_ERROR "You're on Windows but BCrypt seems to be unavailable, you will need OpenSSL")
endif()
endif()
Expand Down
9 changes: 9 additions & 0 deletions cmake/tryCompileTestBCrypt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <Windows.h>
#include <bcrypt.h>
#include <cstdio>
#pragma comment(lib, "bcrypt.lib")

int main(int, char **)
{
printf("%p\n", &BCryptEncrypt);
}

0 comments on commit 5020374

Please sign in to comment.