[libssh2,libgit2,vcpkg-ci-libgit2] Fix, test, cleanup (#32440)

This commit is contained in:
Kai Pastor 2023-07-11 20:18:41 +02:00 committed by GitHub
parent 62c4a7ad63
commit 505cba2668
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 246 additions and 77 deletions

View File

@ -0,0 +1,26 @@
diff --git a/src/libgit2/CMakeLists.txt b/src/libgit2/CMakeLists.txt
index c2a97e1..8c5b2ea 100644
--- a/src/libgit2/CMakeLists.txt
+++ b/src/libgit2/CMakeLists.txt
@@ -2,7 +2,7 @@
# git library functionality.
add_library(libgit2 OBJECT)
-set_target_properties(libgit2 PROPERTIES C_STANDARD 90)
+set_target_properties(libgit2 PROPERTIES C_STANDARD 99)
set_target_properties(libgit2 PROPERTIES C_EXTENSIONS OFF)
include(PkgBuildConfig)
diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt
index ee35eb9..158fac2 100644
--- a/src/util/CMakeLists.txt
+++ b/src/util/CMakeLists.txt
@@ -1,7 +1,7 @@
# util: a shared library for common utility functions for libgit2 projects
add_library(util OBJECT)
-set_target_properties(util PROPERTIES C_STANDARD 90)
+set_target_properties(util PROPERTIES C_STANDARD 99)
set_target_properties(util PROPERTIES C_EXTENSIONS OFF)
configure_file(git2_features.h.in git2_features.h)

View File

@ -0,0 +1,12 @@
diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt
index 84b6c19..df2119c 100644
--- a/src/cli/CMakeLists.txt
+++ b/src/cli/CMakeLists.txt
@@ -46,6 +46,7 @@ set_target_properties(git2_cli PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
ide_split_sources(git2_cli)
target_include_directories(git2_cli PRIVATE ${CLI_INCLUDES})
+target_include_directories(git2_cli SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
if(MSVC_IDE)
# Precompiled headers

View File

@ -0,0 +1,41 @@
diff --git a/cmake/SelectRegex.cmake b/cmake/SelectRegex.cmake
index 2a3a91b..523fa72 100644
--- a/cmake/SelectRegex.cmake
+++ b/cmake/SelectRegex.cmake
@@ -17,7 +17,9 @@ if(REGEX_BACKEND STREQUAL "regcomp_l")
add_feature_info(regex ON "using system regcomp_l")
set(GIT_REGEX_REGCOMP_L 1)
elseif(REGEX_BACKEND STREQUAL "pcre2")
- find_package(PCRE2)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(PCRE2 REQUIRED libpcre2-8)
+ set(PCRE2_LIBRARIES "${PCRE2_LINK_LIBRARIES}")
if(NOT PCRE2_FOUND)
MESSAGE(FATAL_ERROR "PCRE2 support was requested but not found")
@@ -33,6 +35,9 @@ elseif(REGEX_BACKEND STREQUAL "pcre")
add_feature_info(regex ON "using system PCRE")
set(GIT_REGEX_PCRE 1)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(PCRE REQUIRED libpcre)
+ set(PCRE_LIBRARIES "${PCRE_LINK_LIBRARIES}")
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS})
list(APPEND LIBGIT2_SYSTEM_LIBS ${PCRE_LIBRARIES})
list(APPEND LIBGIT2_PC_REQUIRES "libpcre")
diff --git a/cmake/SelectSSH.cmake b/cmake/SelectSSH.cmake
index 23dfc97..f481527 100644
--- a/cmake/SelectSSH.cmake
+++ b/cmake/SelectSSH.cmake
@@ -1,6 +1,10 @@
# Optional external dependency: libssh2
if(USE_SSH)
- find_pkglibraries(LIBSSH2 libssh2)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(LIBSSH2 REQUIRED libssh2)
+ set(LIBSSH2_LIBRARIES "${LIBSSH2_LINK_LIBRARIES}")
+ set(LIBSSH2_LDFLAGS "")
+ list(APPEND LIBGIT2_PC_REQUIRES "libssh2")
if(NOT LIBSSH2_FOUND)
find_package(LibSSH2)
set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})

View File

@ -1,55 +0,0 @@
diff --git a/cmake/SelectRegex.cmake b/cmake/SelectRegex.cmake
index 2a3a91b8c..cbb409350 100644
--- a/cmake/SelectRegex.cmake
+++ b/cmake/SelectRegex.cmake
@@ -1,5 +1,4 @@
# Specify regular expression implementation
-find_package(PCRE)
if(REGEX_BACKEND STREQUAL "")
check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
@@ -33,8 +32,8 @@ elseif(REGEX_BACKEND STREQUAL "pcre")
add_feature_info(regex ON "using system PCRE")
set(GIT_REGEX_PCRE 1)
- list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS})
- list(APPEND LIBGIT2_SYSTEM_LIBS ${PCRE_LIBRARIES})
+ find_package(unofficial-pcre CONFIG REQUIRED)
+ list(APPEND LIBGIT2_SYSTEM_LIBS unofficial::pcre::pcre)
list(APPEND LIBGIT2_PC_REQUIRES "libpcre")
elseif(REGEX_BACKEND STREQUAL "regcomp")
add_feature_info(regex ON "using system regcomp")
diff --git a/src/libgit2/CMakeLists.txt b/src/libgit2/CMakeLists.txt
index 876a703e8..8283f9585 100644
--- a/src/libgit2/CMakeLists.txt
+++ b/src/libgit2/CMakeLists.txt
@@ -110,10 +110,28 @@ FILE(WRITE "${PROJECT_BINARY_DIR}/include/${LIBGIT2_FILENAME}.h" ${LIBGIT2_INCLU
# Install
-install(TARGETS libgit2package
+install(TARGETS libgit2package EXPORT unofficial-git2Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+install(EXPORT unofficial-git2Targets
+ NAMESPACE unofficial::git2::
+ DESTINATION share/unofficial-git2
+)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-git2-config.cmake.in"
+[[include(CMakeFindDependencyMacro)
+if(@USE_BUNDLED_ZLIB@ STREQUAL "OFF")
+ find_dependency(ZLIB)
+endif()
+if(@REGEX_BACKEND@ STREQUAL "pcre")
+ find_dependency(unofficial-pcre CONFIG)
+endif()
+include("${CMAKE_CURRENT_LIST_DIR}/unofficial-git2Targets.cmake")
+]])
+configure_file("${CMAKE_CURRENT_BINARY_DIR}/unofficial-git2-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-git2-config.cmake" @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-git2-config.cmake DESTINATION share/unofficial-git2)
+
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/git2/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBGIT2_FILENAME}")
install(FILES ${PROJECT_BINARY_DIR}/include/git2/experimental.h

View File

@ -0,0 +1,13 @@
diff --git a/cmake/SelectWinHTTP.cmake b/cmake/SelectWinHTTP.cmake
index 96e0bdb..31c3a56 100644
--- a/cmake/SelectWinHTTP.cmake
+++ b/cmake/SelectWinHTTP.cmake
@@ -3,7 +3,7 @@ if(WIN32 AND USE_WINHTTP)
# Since MinGW does not come with headers or an import library for winhttp,
# we have to include a private header and generate our own import library
- if(MINGW)
+ if(0)
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/winhttp" "${PROJECT_BINARY_DIR}/deps/winhttp")
list(APPEND LIBGIT2_SYSTEM_LIBS winhttp)
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/winhttp")

View File

@ -5,10 +5,21 @@ vcpkg_from_github(
SHA512 fd73df91710f19b0d6c3765c37c7f529233196da91cf4d58028a8d3840244f11df44abafabd74a8ed1cbe4826d1afd6ff9f01316d183ace0924c65e7cf0eb8d5
HEAD_REF maint/v1.6
PATCHES
fix-configcmake.patch
c-standard.diff # for 'inline' in system headers
cli-include-dirs.diff
dependencies.diff
mingw-winhttp.diff
unofficial-config-export.diff
)
file(REMOVE_RECURSE
"${SOURCE_PATH}/cmake/FindPCRE.cmake"
"${SOURCE_PATH}/cmake/FindPCRE2.cmake"
"${SOURCE_PATH}/deps/chromium-zlib"
"${SOURCE_PATH}/deps/http-parser"
"${SOURCE_PATH}/deps/pcre"
"${SOURCE_PATH}/deps/winhttp"
"${SOURCE_PATH}/deps/zlib"
)
file(REMOVE_RECURSE "${SOURCE_PATH}/cmake/FindPCRE.cmake")
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" STATIC_CRT)
@ -29,10 +40,6 @@ function(set_tls_backend VALUE)
set(USE_HTTPS ${VALUE} PARENT_SCOPE)
endfunction()
if("openssl" IN_LIST FEATURES)
list(APPEND GIT_OPTIONS "-DGIT_OPENSSL=1")
endif()
foreach(GIT2_FEATURE ${FEATURES})
if(GIT2_FEATURE STREQUAL "pcre")
set_regex_backend("pcre")
@ -53,10 +60,13 @@ if(NOT REGEX_BACKEND)
message(FATAL_ERROR "Must choose pcre or pcre2 regex backend")
endif()
vcpkg_find_acquire_program(PKGCONFIG)
vcpkg_check_features(
OUT_FEATURE_OPTIONS GIT2_FEATURES
FEATURES
ssh USE_SSH
FEATURES
ssh USE_SSH
tools BUILD_CLI
)
vcpkg_cmake_configure(
@ -67,15 +77,36 @@ vcpkg_cmake_configure(
-DUSE_HTTPS=${USE_HTTPS}
-DREGEX_BACKEND=${REGEX_BACKEND}
-DSTATIC_CRT=${STATIC_CRT}
-DBUILD_CLI=OFF
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
-DCMAKE_DISABLE_FIND_PACKAGE_GSSAPI:BOOL=ON
${GIT2_FEATURES}
${GIT_OPTIONS}
OPTIONS_DEBUG
-DBUILD_CLI=OFF
MAYBE_UNUSED_VARIABLES
STATIC_CRT
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-git2 CONFIG_PATH share/unofficial-git2)
vcpkg_fixup_pkgconfig()
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/unofficial-git2-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/unofficial-git2")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/unofficial-libgit2-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/unofficial-libgit2")
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-libgit2 CONFIG_PATH share/unofficial-libgit2)
if("tools" IN_LIST FEATURES)
vcpkg_copy_tools(TOOL_NAMES git2 AUTO_CLEAN)
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
set(file_list "${SOURCE_PATH}/COPYING")
if(NOT VCPKG_TARGET_IS_WINDOWS)
file(WRITE "${CURRENT_BUILDTREES_DIR}/Notice for ntlmclient" [[
Copyright (c) Edward Thomson. All rights reserved.
These source files are part of ntlmclient, distributed under the MIT license.
]])
list(APPEND file_list "${CURRENT_BUILDTREES_DIR}/Notice for ntlmclient")
endif()
vcpkg_install_copyright(FILE_LIST ${file_list})

View File

@ -0,0 +1,21 @@
diff --git a/src/libgit2/CMakeLists.txt b/src/libgit2/CMakeLists.txt
index dcb4279..20acdc8 100644
--- a/src/libgit2/CMakeLists.txt
+++ b/src/libgit2/CMakeLists.txt
@@ -128,10 +128,16 @@ FILE(WRITE "${PROJECT_BINARY_DIR}/include/${LIBGIT2_FILENAME}.h" ${LIBGIT2_INCLU
# Install
+target_include_directories(libgit2package SYSTEM PUBLIC $<INSTALL_INTERFACE:include>)
install(TARGETS libgit2package
+ EXPORT unofficial-libgit2-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(EXPORT unofficial-libgit2-targets
+ NAMESPACE unofficial::libgit2::
+ DESTINATION share/unofficial-libgit2
+)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/git2/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBGIT2_FILENAME}")
install(FILES ${PROJECT_BINARY_DIR}/include/git2/experimental.h

View File

@ -0,0 +1,6 @@
file(READ "${CMAKE_CURRENT_LIST_DIR}/../unofficial-libgit2/usage" usage)
message(WARNING "find_package(unofficial-git2) is deprecated.\n${usage}")
include(CMakeFindDependencyMacro)
find_dependency(unofficial-libgit2 CONFIG)
add_library(unofficial::git2::libgit2package INTERFACE IMPORTED)
set_target_properties(unofficial::git2::libgit2package PROPERTIES INTERFACE_LINK_LIBRARIES unofficial::libgit2::libgit2package)

View File

@ -0,0 +1,3 @@
include("${CMAKE_CURRENT_LIST_DIR}/unofficial-libgit2-targets.cmake")
add_library(unofficial::libgit2::libgit2 INTERFACE IMPORTED)
set_target_properties(unofficial::libgit2::libgit2 PROPERTIES INTERFACE_LINK_LIBRARIES unofficial::libgit2::libgit2package)

11
ports/libgit2/usage Normal file
View File

@ -0,0 +1,11 @@
libgit2 can be imported via CMake FindPkgConfig module:
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBGIT2 REQUIRED IMPORTED_TARGET libgit2)
target_link_libraries(main PRIVATE PkgConfig::LIBGIT2)
vcpkg provides proprietary CMake targets:
find_package(unofficial-libgit2 CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::libgit2::libgit2)

View File

@ -1,8 +1,10 @@
{
"name": "libgit2",
"version-semver": "1.6.4",
"description": "Git linkable library",
"port-version": 1,
"description": "A C library implementing the Git core methods with a solid API",
"homepage": "https://github.com/libgit2/libgit2",
"license": null,
"supports": "!uwp",
"dependencies": [
"http-parser",
@ -85,6 +87,9 @@
}
]
},
"tools": {
"description": "Build CLI tools"
},
"winhttp": {
"description": "SSL support (WinHTTP)",
"supports": "windows & !uwp"

View File

@ -8,8 +8,17 @@ vcpkg_from_github(
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
zlib ENABLE_ZLIB_COMPRESSION
zlib ENABLE_ZLIB_COMPRESSION
INVERTED_FEATURES
zlib CMAKE_DISABLE_FIND_PACKAGE_ZLIB # for use by the cryto backend
)
if("openssl" IN_LIST FEATURES)
list(APPEND FEATURE_OPTIONS "-DCRYPTO_BACKEND=OpenSSL")
elseif(VCPKG_TARGET_IS_WINDOWS)
list(APPEND FEATURE_OPTIONS "-DCRYPTO_BACKEND=WinCNG")
else()
message(FATAL_ERROR "Port ${PORT} only supports OpenSSL and WinCNG crypto backends.")
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
list(APPEND FEATURE_OPTIONS "-DBUILD_STATIC_LIBS:BOOL=OFF")
endif()
@ -22,6 +31,8 @@ vcpkg_cmake_configure(
${FEATURE_OPTIONS}
OPTIONS_DEBUG
-DENABLE_DEBUG_LOGGING=OFF
MAYBE_UNUSED_VARIABLES
CMAKE_DISABLE_FIND_PACKAGE_ZLIB
)
vcpkg_cmake_install()
@ -37,6 +48,12 @@ if (VCPKG_TARGET_IS_WINDOWS)
else()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libssh2.h" "ifdef _WINDLL" "if 0")
endif()
if(VCPKG_TARGET_STATIC_LIBRARY_PREFIX STREQUAL "")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libssh2.pc" " -lssh2" " -llibssh2")
if(NOT VCPKG_BUILD_TYPE)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libssh2.pc" " -lssh2" " -llibssh2")
endif()
endif()
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

View File

@ -1,11 +1,19 @@
{
"name": "libssh2",
"version": "1.11.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": "libssh2",
"default-features": false,
"features": [
"openssl"
],
"platform": "!windows"
},
{
"name": "vcpkg-cmake",
"host": true
@ -16,11 +24,18 @@
}
],
"default-features": [
"openssl",
"zlib"
],
"features": {
"openssl": {
"description": "Use the openssl crypto backend",
"dependencies": [
"openssl"
]
},
"zlib": {
"description": "Use compressing via zlib",
"description": "Use compression via zlib",
"dependencies": [
"zlib"
]

View File

@ -578,9 +578,6 @@ libcpplocate:x64-android=fail
libcrafter:arm-neon-android=fail
libcrafter:arm64-android=fail
libcrafter:x64-android=fail
libgit2:arm-neon-android=fail
libgit2:arm64-android=fail
libgit2:x64-android=fail
libgo:x64-android=fail
libgpg-error:arm-neon-android=fail
libgpg-error:arm64-android=fail

View File

@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

View File

@ -0,0 +1,15 @@
{
"name": "vcpkg-ci-libgit2",
"version-string": "ci",
"description": "Validates libgit2 with ssh and tools.",
"dependencies": [
{
"name": "libgit2",
"default-features": false,
"features": [
"ssh",
"tools"
]
}
]
}

View File

@ -4106,7 +4106,7 @@
},
"libgit2": {
"baseline": "1.6.4",
"port-version": 0
"port-version": 1
},
"libgme": {
"baseline": "0.6.3",
@ -4622,7 +4622,7 @@
},
"libssh2": {
"baseline": "1.11.0",
"port-version": 0
"port-version": 1
},
"libstemmer": {
"baseline": "2017-9",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "7a3e64338633f5a89dca3586094f3f156f5a0a42",
"version-semver": "1.6.4",
"port-version": 1
},
{
"git-tree": "e400f294d284f6a7ff3a19b2454c919873405f08",
"version-semver": "1.6.4",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "a17fdd9cf1d6c1f7af5967ee961a41c6dcc40788",
"version": "1.11.0",
"port-version": 1
},
{
"git-tree": "e57c6157ce67a01ce0b98152d9ccfd544e32b381",
"version": "1.11.0",