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:
@@ -1,69 +1,62 @@
|
||||
# Copyright (C) The libssh2 project and its contributors.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# - Try to find mbedTLS
|
||||
# Once done this will define
|
||||
#
|
||||
###########################################################################
|
||||
# Find the mbedtls library
|
||||
#
|
||||
# Input variables:
|
||||
#
|
||||
# MBEDTLS_INCLUDE_DIR The mbedtls include directory
|
||||
# MBEDCRYPTO_LIBRARY Path to mbedcrypto 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
|
||||
# Read-Only variables
|
||||
# MBEDTLS_FOUND - system has mbedTLS
|
||||
# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
|
||||
# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
|
||||
# MBEDTLS_LIBRARIES - Link these to use mbedTLS
|
||||
# MBEDTLS_LIBRARY - path to mbedTLS library
|
||||
# MBEDX509_LIBRARY - path to mbedTLS X.509 library
|
||||
# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
|
||||
|
||||
if((UNIX OR VCPKG_TOOLCHAIN OR (MINGW AND NOT CMAKE_CROSSCOMPILING)) AND
|
||||
NOT DEFINED MBEDTLS_INCLUDE_DIR AND
|
||||
NOT DEFINED MBEDCRYPTO_LIBRARY)
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(MBEDTLS "mbedcrypto")
|
||||
find_path(MBEDTLS_INCLUDE_DIR mbedtls/version.h)
|
||||
|
||||
if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
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()
|
||||
|
||||
if(MBEDTLS_FOUND)
|
||||
string(REPLACE ";" " " MBEDTLS_CFLAGS "${MBEDTLS_CFLAGS}")
|
||||
message(STATUS "Found MbedTLS (via pkg-config): ${MBEDTLS_INCLUDE_DIRS} (found version \"${MBEDTLS_VERSION}\")")
|
||||
else()
|
||||
find_path(MBEDTLS_INCLUDE_DIR NAMES "mbedtls/version.h")
|
||||
find_library(MBEDCRYPTO_LIBRARY NAMES "mbedcrypto" "libmbedcrypto")
|
||||
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
|
||||
get_filename_component(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
|
||||
get_filename_component(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
|
||||
get_filename_component(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
|
||||
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(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h") # 3.x
|
||||
set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h")
|
||||
elseif(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h") # 2.x
|
||||
set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h")
|
||||
else()
|
||||
unset(_version_header)
|
||||
if(NOT MBEDTLS_FIND_QUIETLY)
|
||||
message(STATUS "Found mbedTLS:")
|
||||
file(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
|
||||
string(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
|
||||
if(MBEDTLSMATCH)
|
||||
string(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
|
||||
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)
|
||||
message(STATUS " TLS: ${MBEDTLS_LIBRARY}")
|
||||
message(STATUS " X509: ${MBEDX509_LIBRARY}")
|
||||
message(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
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)
|
||||
elseif(MBEDTLS_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find mbedTLS")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
MBEDTLS_INCLUDE_DIR
|
||||
MBEDTLS_LIBRARY_DIR
|
||||
MBEDTLS_LIBRARIES
|
||||
MBEDTLS_LIBRARY
|
||||
MBEDX509_LIBRARY
|
||||
MBEDCRYPTO_LIBRARY
|
||||
)
|
||||
|
||||
@@ -1,59 +1,41 @@
|
||||
# Copyright (C) The libssh2 project and its contributors.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
###########################################################################
|
||||
# Find the wolfssl library
|
||||
#
|
||||
# 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
|
||||
# - Try to find wolfssl
|
||||
# Once done this will define
|
||||
# WOLFSSL_FOUND - System has wolfssl
|
||||
# WOLFSSL_INCLUDE_DIR - The wolfssl include directories
|
||||
# WOLFSSL_LIBRARIES - The libraries needed to use wolfssl
|
||||
|
||||
if((UNIX OR VCPKG_TOOLCHAIN OR (MINGW AND NOT CMAKE_CROSSCOMPILING)) AND
|
||||
NOT DEFINED WOLFSSL_INCLUDE_DIR AND
|
||||
NOT DEFINED WOLFSSL_LIBRARY)
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(WOLFSSL "wolfssl")
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_WOLFSSL QUIET wolfssl)
|
||||
|
||||
find_path(WOLFSSL_INCLUDE_DIR
|
||||
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()
|
||||
|
||||
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)
|
||||
string(REPLACE ";" " " WOLFSSL_CFLAGS "${WOLFSSL_CFLAGS}")
|
||||
message(STATUS "Found WolfSSL (via pkg-config): ${WOLFSSL_INCLUDE_DIRS} (found version \"${WOLFSSL_VERSION}\")")
|
||||
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)
|
||||
set(WOLFSSL_INCLUDE_DIRS ${WOLFSSL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
mark_as_advanced(WOLFSSL_INCLUDE_DIR WOLFSSL_LIBRARY)
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<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>
|
||||
<PrecompiledHeaderOutputFile>.\Release_dll\libssh2.pch</PrecompiledHeaderOutputFile>
|
||||
<ObjectFileName>.\Release_dll\</ObjectFileName>
|
||||
@@ -103,7 +103,7 @@
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>..\..\..\nmap-mswin32-aux\OpenSSL\include;..\..\libz;..\win32;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;LIBSSH2_WIN32;LIBSSH2_OPENSSL;_LIB;LIBSSH2DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\Debug_dll\</AssemblerListingLocation>
|
||||
@@ -146,6 +146,8 @@
|
||||
<ClCompile Include="..\src\blowfish.c" />
|
||||
<ClCompile Include="..\src\channel.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\crypto.c" />
|
||||
<ClCompile Include="..\src\global.c" />
|
||||
@@ -153,14 +155,12 @@
|
||||
<ClCompile Include="..\src\keepalive.c" />
|
||||
<ClCompile Include="..\src\kex.c" />
|
||||
<ClCompile Include="..\src\knownhost.c" />
|
||||
<ClCompile Include="..\src\libgcrypt.c" />
|
||||
<ClCompile Include="..\src\mac.c" />
|
||||
<ClCompile Include="..\src\mbedtls.c" />
|
||||
<ClCompile Include="..\src\misc.c" />
|
||||
<ClCompile Include="..\src\openssl.c" />
|
||||
<ClCompile Include="..\src\os400qc3.c" />
|
||||
<ClCompile Include="..\src\packet.c" />
|
||||
<ClCompile Include="..\src\pem.c" />
|
||||
<ClCompile Include="..\src\poly1305.c" />
|
||||
<ClCompile Include="..\src\publickey.c" />
|
||||
<ClCompile Include="..\src\scp.c" />
|
||||
<ClCompile Include="..\src\session.c" />
|
||||
@@ -175,9 +175,11 @@
|
||||
<ClInclude Include="..\src\agent.h" />
|
||||
<ClInclude Include="..\src\blf.h" />
|
||||
<ClInclude Include="..\src\channel.h" />
|
||||
<ClInclude Include="..\src\cipher-chachapoly.h" />
|
||||
<ClInclude Include="..\src\comp.h" />
|
||||
<ClInclude Include="..\src\crypto.h" />
|
||||
<ClInclude Include="..\src\libgcrypt.h" />
|
||||
<ClInclude Include="..\src\crypto_config.h" />
|
||||
<ClInclude Include="..\src\libssh2_priv.h" />
|
||||
<ClInclude Include="..\src\libssh2_setup.h" />
|
||||
<ClInclude Include="..\src\mac.h" />
|
||||
@@ -186,6 +188,7 @@
|
||||
<ClInclude Include="..\src\openssl.h" />
|
||||
<ClInclude Include="..\src\os400qc3.h" />
|
||||
<ClInclude Include="..\src\packet.h" />
|
||||
<ClInclude Include="..\src\poly1305.h" />
|
||||
<ClInclude Include="..\src\session.h" />
|
||||
<ClInclude Include="..\src\sftp.h" />
|
||||
<ClInclude Include="..\src\transport.h" />
|
||||
|
||||
Reference in New Issue
Block a user