diff --git a/CMakeLists.txt b/CMakeLists.txt index aa612e70..c2e6601f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,20 +342,39 @@ if(WITH_APPLETLS) endif() endif() +function(a2_wrap_find_library var_name lib) + message(STATUS "Looking for ${lib}") + find_library(${var_name} ${lib}) + if(${var_name}) + message(STATUS "Looking for ${lib} - found") + else() + message(STATUS "Looking for ${lib} - not found") + endif() +endfunction() + set(HAVE_WINTLS no CACHE BOOL "Define if you have Windows TLS support" FORCE) set(HAVE_WINTLS_LIBS false) set(HAVE_WINTLS_HEADERS false) if(WITH_WINTLS) if(WIN32) - find_library(HAVE_WINTLS_LIBS crypt32) - find_library(HAVE_WINTLS_LIBS secur32) - find_library(HAVE_WINTLS_LIBS advapi32) + a2_wrap_find_library(HAVE_CRYPT32 crypt32) + a2_wrap_find_library(HAVE_SECURE32 secur32) + a2_wrap_find_library(HAVE_ADVAPI32 advapi32) + + if(HAVE_CRYPT32 AND HAVE_SECURE32 AND HAVE_ADVAPI32) + set(HAVE_WINTLS_LIBS true) + endif() + check_include_file_cxx(wincrypt.h HAVE_WINCRYPT_H) if(HAVE_WINCRYPT_H) list(APPEND a2_found_headers wincrypt.h) endif() - list(APPEND CMAKE_REQUIRED_DEFINITIONS "/D SECURITY_WIN32") + if(MSVC) + list(APPEND CMAKE_REQUIRED_DEFINITIONS "/D SECURITY_WIN32=1") + else() + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DSECURITY_WIN32=1) + endif() check_include_file_cxx(security.h HAVE_SECURITY_H) if(HAVE_SECURITY_H) list(APPEND a2_found_headers security.h)