[libssh2] Fix various issues + add features (#23327)

* [libssh2] Fix various issues

* Remove dynamic linking

* Add feature zlib

* Disable dynamic linking on Windows and UWP

* version

* Use MSBuild generator on Windows

* version

* Hack for generator on OSX

* version

* Fix windows dynamic build

* version

Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
This commit is contained in:
Thomas1664 2022-03-03 21:52:10 +01:00 committed by GitHub
parent fc568b1867
commit 75ae1ef844
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 51 deletions

View File

@ -0,0 +1,19 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2539607..eceb5a0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -355,9 +355,12 @@ target_include_directories(libssh2 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
# Daniel's note: this should not be necessary and we need to work to
# get this removed.
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows" OR ${CMAKE_SYSTEM_NAME} STREQUAL "WindowsStore")
- target_compile_definitions(libssh2 PRIVATE LIBSSH2_WIN32)
+ target_compile_definitions(libssh2 PUBLIC LIBSSH2_WIN32)
+ if (BUILD_SHARED_LIBS)
+ target_compile_definitions(libssh2 PUBLIC _WINDLL PRIVATE LIBSSH2_LIBRARY)
+ endif()
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
- target_compile_definitions(libssh2 PRIVATE LIBSSH2_DARWIN)
+ target_compile_definitions(libssh2 PUBLIC LIBSSH2_DARWIN)
endif()
if(MSVC)

View File

@ -1,41 +0,0 @@
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
* Copyright (c) 2005,2006 Mikhail Gusarov <dottedmag@dottedmag.net>
* Copyright (c) 2006-2007 The Written Word, Inc.
* Copyright (c) 2007 Eli Fant <elifantu@mail.ru>
* Copyright (c) 2009-2014 Daniel Stenberg
* Copyright (C) 2008, 2009 Simon Josefsson
* All rights reserved.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* Neither the name of the copyright holder nor the names
* of any other contributors may be used to endorse or
* promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*/

View File

@ -4,20 +4,39 @@ vcpkg_from_github(
REF libssh2-1.10.0
SHA512 615E28880695911F5700CC7AC3DDA6B894384C0B1D8B02B53C2EB58F1839F47211934A292F490AD7DDEF7E63F332E0EBF44F8E6334F64BE8D143C72032356C1F
HEAD_REF master
PATCHES "${CMAKE_CURRENT_LIST_DIR}/0001-Fix-UWP.patch"
PATCHES
0001-Fix-UWP.patch
0002-fix-macros.patch
)
vcpkg_configure_cmake(
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
zlib ENABLE_ZLIB_COMPRESSION
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_EXAMPLES=OFF
-DBUILD_TESTING=OFF
-DENABLE_ZLIB_COMPRESSION=ON
${FEATURE_OPTIONS}
OPTIONS_DEBUG
-DENABLE_DEBUG_LOGGING=OFF
)
vcpkg_install_cmake()
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/libssh2)
if (VCPKG_TARGET_IS_WINDOWS)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libssh2.h" "ifdef LIBSSH2_WIN32" "if 1")
if (VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libssh2.h" "ifdef _WINDLL" "if 1")
else()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libssh2.h" "ifdef _WINDLL" "if 0")
endif()
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig")
@ -25,8 +44,5 @@ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share")
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/libssh2)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/libssh2" RENAME copyright)
vcpkg_copy_pdbs()
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -1,10 +1,30 @@
{
"name": "libssh2",
"version": "1.10.0",
"port-version": 1,
"description": "libssh2 is a client-side C library implementing the SSH2 protocol.",
"homepage": "https://www.libssh2.org",
"license": "BSD-3-Clause",
"dependencies": [
"openssl",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"default-features": [
"zlib"
]
],
"features": {
"zlib": {
"description": "Use compressing via zlib",
"dependencies": [
"zlib"
]
}
}
}

View File

@ -3990,7 +3990,7 @@
},
"libssh2": {
"baseline": "1.10.0",
"port-version": 0
"port-version": 1
},
"libstemmer": {
"baseline": "2017-9",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "3c6dd977de517dc2091377a58c55b7d23f2bc3a0",
"version": "1.10.0",
"port-version": 1
},
{
"git-tree": "996df01b95684f41e8870b9154aeea3bffc63840",
"version": "1.10.0",