Skip to content

Commit 5020374

Browse files
malytomaszpostfacto
authored andcommitted
improved test if bcrypt is available
1 parent 6aa4e78 commit 5020374

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ if (WIN32)
8888
#
8989
# Check whether BCrypt can be used with this SDK version
9090
#
91-
cmake_push_check_state()
92-
set(CMAKE_REQUIRED_LIBRARIES bcrypt)
93-
check_symbol_exists(BCryptEncrypt windows.h BCRYPT_AVAILABLE)
94-
cmake_pop_check_state()
91+
try_compile(BCRYPT_AVAILABLE "${CMAKE_CURRENT_BINARY_DIR}/tryCompile" SOURCES "${CMAKE_CURRENT_LIST_DIR}/cmake/tryCompileTestBCrypt.cpp" OUTPUT_VARIABLE BCRYPT_AVAILABILITY_TEST_MESSAGES)
9592
if (NOT BCRYPT_AVAILABLE)
93+
message(STATUS ${BCRYPT_AVAILABILITY_TEST_MESSAGES})
9694
message(FATAL_ERROR "You're on Windows but BCrypt seems to be unavailable, you will need OpenSSL")
9795
endif()
9896
endif()

cmake/tryCompileTestBCrypt.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <Windows.h>
2+
#include <bcrypt.h>
3+
#include <cstdio>
4+
#pragma comment(lib, "bcrypt.lib")
5+
6+
int main(int, char **)
7+
{
8+
printf("%p\n", &BCryptEncrypt);
9+
}

0 commit comments

Comments
 (0)