1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

libssh2: windows build fixes

This commit is contained in:
dmiller
2025-04-15 23:55:02 +00:00
parent 2f750998ef
commit 0ed7a14706
3 changed files with 97 additions and 119 deletions

View File

@@ -1,69 +1,62 @@
# Copyright (C) The libssh2 project and its contributors. # - Try to find mbedTLS
# SPDX-License-Identifier: BSD-3-Clause # Once done this will define
# #
########################################################################### # Read-Only variables
# Find the mbedtls library # MBEDTLS_FOUND - system has mbedTLS
# # MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
# Input variables: # MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
# # MBEDTLS_LIBRARIES - Link these to use mbedTLS
# MBEDTLS_INCLUDE_DIR The mbedtls include directory # MBEDTLS_LIBRARY - path to mbedTLS library
# MBEDCRYPTO_LIBRARY Path to mbedcrypto library # MBEDX509_LIBRARY - path to mbedTLS X.509 library
# # MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
# Result variables:
#
# MBEDTLS_FOUND System has mbedtls
# MBEDTLS_INCLUDE_DIRS The mbedtls include directories
# MBEDTLS_LIBRARIES The mbedtls library names
# MBEDTLS_LIBRARY_DIRS The mbedtls library directories
# MBEDTLS_CFLAGS Required compiler flags
# MBEDTLS_VERSION Version of mbedtls
if((UNIX OR VCPKG_TOOLCHAIN OR (MINGW AND NOT CMAKE_CROSSCOMPILING)) AND find_path(MBEDTLS_INCLUDE_DIR mbedtls/version.h)
NOT DEFINED MBEDTLS_INCLUDE_DIR AND
NOT DEFINED MBEDCRYPTO_LIBRARY) if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
find_package(PkgConfig QUIET) # Already in cache, be silent
pkg_check_modules(MBEDTLS "mbedcrypto") set(MBEDTLS_FIND_QUIETLY TRUE)
endif()
find_library(MBEDTLS_LIBRARY NAMES mbedtls libmbedtls libmbedx509)
find_library(MBEDX509_LIBRARY NAMES mbedx509 libmbedx509)
find_library(MBEDCRYPTO_LIBRARY NAMES mbedcrypto libmbedcrypto)
if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
set(MBEDTLS_FOUND TRUE)
endif() endif()
if(MBEDTLS_FOUND) if(MBEDTLS_FOUND)
string(REPLACE ";" " " MBEDTLS_CFLAGS "${MBEDTLS_CFLAGS}") # split mbedTLS into -L and -l linker options, so we can set them for pkg-config
message(STATUS "Found MbedTLS (via pkg-config): ${MBEDTLS_INCLUDE_DIRS} (found version \"${MBEDTLS_VERSION}\")") get_filename_component(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
else() get_filename_component(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
find_path(MBEDTLS_INCLUDE_DIR NAMES "mbedtls/version.h") get_filename_component(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
find_library(MBEDCRYPTO_LIBRARY NAMES "mbedcrypto" "libmbedcrypto") get_filename_component(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
string(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
string(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
string(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
set(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
if(MBEDTLS_INCLUDE_DIR) if(NOT MBEDTLS_FIND_QUIETLY)
if(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h") # 3.x message(STATUS "Found mbedTLS:")
set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h") file(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
elseif(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h") # 2.x string(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h") if(MBEDTLSMATCH)
else() string(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
unset(_version_header) message(STATUS " version ${MBEDTLS_VERSION}")
endif()
if(_version_header)
set(_version_regex "#[\t ]*define[\t ]+MBEDTLS_VERSION_STRING[\t ]+\"([0-9.]+)\"")
file(STRINGS "${_version_header}" _version_str REGEX "${_version_regex}")
string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
set(MBEDTLS_VERSION "${_version_str}")
unset(_version_regex)
unset(_version_str)
unset(_version_header)
endif() endif()
message(STATUS " TLS: ${MBEDTLS_LIBRARY}")
message(STATUS " X509: ${MBEDX509_LIBRARY}")
message(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
endif() endif()
elseif(MBEDTLS_FIND_REQUIRED)
include(FindPackageHandleStandardArgs) message(FATAL_ERROR "Could not find mbedTLS")
find_package_handle_standard_args(MbedTLS
REQUIRED_VARS
MBEDTLS_INCLUDE_DIR
MBEDCRYPTO_LIBRARY
VERSION_VAR
MBEDTLS_VERSION
)
if(MBEDTLS_FOUND)
set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
set(MBEDTLS_LIBRARIES ${MBEDCRYPTO_LIBRARY})
endif()
mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDCRYPTO_LIBRARY)
endif() endif()
mark_as_advanced(
MBEDTLS_INCLUDE_DIR
MBEDTLS_LIBRARY_DIR
MBEDTLS_LIBRARIES
MBEDTLS_LIBRARY
MBEDX509_LIBRARY
MBEDCRYPTO_LIBRARY
)

View File

@@ -1,59 +1,41 @@
# Copyright (C) The libssh2 project and its contributors. # - Try to find wolfssl
# SPDX-License-Identifier: BSD-3-Clause # Once done this will define
# # WOLFSSL_FOUND - System has wolfssl
########################################################################### # WOLFSSL_INCLUDE_DIR - The wolfssl include directories
# Find the wolfssl library # WOLFSSL_LIBRARIES - The libraries needed to use wolfssl
#
# Input variables:
#
# WOLFSSL_INCLUDE_DIR The wolfssl include directory
# WOLFSSL_LIBRARY Path to wolfssl library
#
# Result variables:
#
# WOLFSSL_FOUND System has wolfssl
# WOLFSSL_INCLUDE_DIRS The wolfssl include directories
# WOLFSSL_LIBRARIES The wolfssl library names
# WOLFSSL_LIBRARY_DIRS The wolfssl library directories
# WOLFSSL_CFLAGS Required compiler flags
# WOLFSSL_VERSION Version of wolfssl
if((UNIX OR VCPKG_TOOLCHAIN OR (MINGW AND NOT CMAKE_CROSSCOMPILING)) AND find_package(PkgConfig QUIET)
NOT DEFINED WOLFSSL_INCLUDE_DIR AND pkg_check_modules(PC_WOLFSSL QUIET wolfssl)
NOT DEFINED WOLFSSL_LIBRARY)
find_package(PkgConfig QUIET) find_path(WOLFSSL_INCLUDE_DIR
pkg_check_modules(WOLFSSL "wolfssl") NAMES wolfssl/ssl.h
HINTS ${PC_WOLFSSL_INCLUDE_DIRS}
)
find_library(WOLFSSL_LIBRARY
NAMES wolfssl
HINTS ${PC_WOLFSSL_LIBRARY_DIRS}
)
if(WOLFSSL_INCLUDE_DIR)
set(_version_regex "^#define[ \t]+LIBWOLFSSL_VERSION_STRING[ \t]+\"([^\"]+)\".*")
file(STRINGS "${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h"
WOLFSSL_VERSION REGEX "${_version_regex}")
string(REGEX REPLACE "${_version_regex}" "\\1"
WOLFSSL_VERSION "${WOLFSSL_VERSION}")
unset(_version_regex)
endif() endif()
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set WOLFSSL_FOUND
# to TRUE if all listed variables are TRUE and the requested version
# matches.
find_package_handle_standard_args(wolfssl REQUIRED_VARS
WOLFSSL_LIBRARY WOLFSSL_INCLUDE_DIR
VERSION_VAR WOLFSSL_VERSION)
if(WOLFSSL_FOUND) if(WOLFSSL_FOUND)
string(REPLACE ";" " " WOLFSSL_CFLAGS "${WOLFSSL_CFLAGS}") set(WOLFSSL_LIBRARIES ${WOLFSSL_LIBRARY})
message(STATUS "Found WolfSSL (via pkg-config): ${WOLFSSL_INCLUDE_DIRS} (found version \"${WOLFSSL_VERSION}\")") set(WOLFSSL_INCLUDE_DIRS ${WOLFSSL_INCLUDE_DIR})
else()
find_path(WOLFSSL_INCLUDE_DIR NAMES "wolfssl/options.h")
find_library(WOLFSSL_LIBRARY NAMES "wolfssl")
if(WOLFSSL_INCLUDE_DIR AND EXISTS "${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h")
set(_version_regex "#[\t ]*define[\t ]+LIBWOLFSSL_VERSION_STRING[\t ]+\"([^\"]*)\"")
file(STRINGS "${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h" _version_str REGEX "${_version_regex}")
string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
set(WOLFSSL_VERSION "${_version_str}")
unset(_version_regex)
unset(_version_str)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WolfSSL
REQUIRED_VARS
WOLFSSL_INCLUDE_DIR
WOLFSSL_LIBRARY
VERSION_VAR
WOLFSSL_VERSION
)
if(WOLFSSL_FOUND)
set(WOLFSSL_INCLUDE_DIRS ${WOLFSSL_INCLUDE_DIR})
set(WOLFSSL_LIBRARIES ${WOLFSSL_LIBRARY})
endif()
mark_as_advanced(WOLFSSL_INCLUDE_DIR WOLFSSL_LIBRARY)
endif() endif()
mark_as_advanced(WOLFSSL_INCLUDE_DIR WOLFSSL_LIBRARY)

View File

@@ -60,7 +60,7 @@
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>..\..\libz;..\..\..\nmap-mswin32-aux\OpenSSL\include;..\win32;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\libz;..\..\..\nmap-mswin32-aux\OpenSSL\include;..\win32;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;LIBSSH2_WIN32;LIBSSH2_OPENSSL;_LIB;LIBSSH2_LIBRARY;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;LIBSSH2_WIN32;LIBSSH2_OPENSSL;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerListingLocation>.\Release_dll\</AssemblerListingLocation> <AssemblerListingLocation>.\Release_dll\</AssemblerListingLocation>
<PrecompiledHeaderOutputFile>.\Release_dll\libssh2.pch</PrecompiledHeaderOutputFile> <PrecompiledHeaderOutputFile>.\Release_dll\libssh2.pch</PrecompiledHeaderOutputFile>
<ObjectFileName>.\Release_dll\</ObjectFileName> <ObjectFileName>.\Release_dll\</ObjectFileName>
@@ -103,7 +103,7 @@
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<TreatWarningAsError>false</TreatWarningAsError> <TreatWarningAsError>false</TreatWarningAsError>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>..\..\..\nmap-mswin32-aux\OpenSSL\include;..\..\libz;..\win32;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\..\nmap-mswin32-aux\OpenSSL\include;..\..\libz;..\win32;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;LIBSSH2_WIN32;LIBSSH2_OPENSSL;_LIB;LIBSSH2DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;LIBSSH2_WIN32;LIBSSH2_OPENSSL;_LIB;LIBSSH2DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerListingLocation>.\Debug_dll\</AssemblerListingLocation> <AssemblerListingLocation>.\Debug_dll\</AssemblerListingLocation>
@@ -146,6 +146,8 @@
<ClCompile Include="..\src\blowfish.c" /> <ClCompile Include="..\src\blowfish.c" />
<ClCompile Include="..\src\channel.c" /> <ClCompile Include="..\src\channel.c" />
<ClCompile Include="..\src\comp.c" /> <ClCompile Include="..\src\comp.c" />
<ClCompile Include="..\src\chacha.c" />
<ClCompile Include="..\src\cipher-chachapoly.c" />
<ClCompile Include="..\src\crypt.c" /> <ClCompile Include="..\src\crypt.c" />
<ClCompile Include="..\src\crypto.c" /> <ClCompile Include="..\src\crypto.c" />
<ClCompile Include="..\src\global.c" /> <ClCompile Include="..\src\global.c" />
@@ -153,14 +155,12 @@
<ClCompile Include="..\src\keepalive.c" /> <ClCompile Include="..\src\keepalive.c" />
<ClCompile Include="..\src\kex.c" /> <ClCompile Include="..\src\kex.c" />
<ClCompile Include="..\src\knownhost.c" /> <ClCompile Include="..\src\knownhost.c" />
<ClCompile Include="..\src\libgcrypt.c" />
<ClCompile Include="..\src\mac.c" /> <ClCompile Include="..\src\mac.c" />
<ClCompile Include="..\src\mbedtls.c" />
<ClCompile Include="..\src\misc.c" /> <ClCompile Include="..\src\misc.c" />
<ClCompile Include="..\src\openssl.c" /> <ClCompile Include="..\src\openssl.c" />
<ClCompile Include="..\src\os400qc3.c" />
<ClCompile Include="..\src\packet.c" /> <ClCompile Include="..\src\packet.c" />
<ClCompile Include="..\src\pem.c" /> <ClCompile Include="..\src\pem.c" />
<ClCompile Include="..\src\poly1305.c" />
<ClCompile Include="..\src\publickey.c" /> <ClCompile Include="..\src\publickey.c" />
<ClCompile Include="..\src\scp.c" /> <ClCompile Include="..\src\scp.c" />
<ClCompile Include="..\src\session.c" /> <ClCompile Include="..\src\session.c" />
@@ -175,9 +175,11 @@
<ClInclude Include="..\src\agent.h" /> <ClInclude Include="..\src\agent.h" />
<ClInclude Include="..\src\blf.h" /> <ClInclude Include="..\src\blf.h" />
<ClInclude Include="..\src\channel.h" /> <ClInclude Include="..\src\channel.h" />
<ClInclude Include="..\src\cipher-chachapoly.h" />
<ClInclude Include="..\src\comp.h" /> <ClInclude Include="..\src\comp.h" />
<ClInclude Include="..\src\crypto.h" /> <ClInclude Include="..\src\crypto.h" />
<ClInclude Include="..\src\libgcrypt.h" /> <ClInclude Include="..\src\libgcrypt.h" />
<ClInclude Include="..\src\crypto_config.h" />
<ClInclude Include="..\src\libssh2_priv.h" /> <ClInclude Include="..\src\libssh2_priv.h" />
<ClInclude Include="..\src\libssh2_setup.h" /> <ClInclude Include="..\src\libssh2_setup.h" />
<ClInclude Include="..\src\mac.h" /> <ClInclude Include="..\src\mac.h" />
@@ -186,6 +188,7 @@
<ClInclude Include="..\src\openssl.h" /> <ClInclude Include="..\src\openssl.h" />
<ClInclude Include="..\src\os400qc3.h" /> <ClInclude Include="..\src\os400qc3.h" />
<ClInclude Include="..\src\packet.h" /> <ClInclude Include="..\src\packet.h" />
<ClInclude Include="..\src\poly1305.h" />
<ClInclude Include="..\src\session.h" /> <ClInclude Include="..\src\session.h" />
<ClInclude Include="..\src\sftp.h" /> <ClInclude Include="..\src\sftp.h" />
<ClInclude Include="..\src\transport.h" /> <ClInclude Include="..\src\transport.h" />