Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 20 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions ports/libgit2/c-standard.diff
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 12 additions & 0 deletions ports/libgit2/cli-include-dirs.diff
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions ports/libgit2/dependencies.diff
Original file line number Diff line number Diff line change
@@ -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})
55 changes: 0 additions & 55 deletions ports/libgit2/fix-configcmake.patch

This file was deleted.

13 changes: 13 additions & 0 deletions ports/libgit2/mingw-winhttp.diff
Original file line number Diff line number Diff line change
@@ -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")
57 changes: 44 additions & 13 deletions ports/libgit2/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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")
Expand All @@ -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(
Expand All @@ -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})
21 changes: 21 additions & 0 deletions ports/libgit2/unofficial-config-export.diff
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions ports/libgit2/unofficial-git2-config.cmake
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions ports/libgit2/unofficial-libgit2-config.cmake
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions ports/libgit2/usage
Original file line number Diff line number Diff line change
@@ -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)

7 changes: 6 additions & 1 deletion ports/libgit2/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -85,6 +87,9 @@
}
]
},
"tools": {
"description": "Build CLI tools"
},
"winhttp": {
"description": "SSL support (WinHTTP)",
"supports": "windows & !uwp"
Expand Down
19 changes: 18 additions & 1 deletion ports/libssh2/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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")
Expand Down
19 changes: 17 additions & 2 deletions ports/libssh2/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
]
Expand Down
Loading
Loading