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

libgit2: add version 1.7.2, support conan v2 #18458

Merged
merged 30 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fd20266
libgit2: add version 1.6.4, support conan v2
toge Jul 10, 2023
40ed77d
set CMP0091 to NEW
toge Jul 17, 2023
28c2bf1
update 1.7.0, fix CMakeLists.txt of 1.0.1
toge Jul 18, 2023
22a6482
support libssh2 in 1.7.0
toge Jul 18, 2023
ecc36e4
Merge branch 'master' into libgit2-1.6.4
toge Jul 18, 2023
c2cd815
fix cmake in 0.27.x and 0.28.x
toge Jul 18, 2023
ae21891
disable CHECK_LIBRARY_EXISTS
toge Jul 18, 2023
b1eaf57
link secur32
toge Jul 19, 2023
a0a0ee5
use `is_msvc()`
toge Jul 20, 2023
e99f103
Merge branch 'master' into libgit2-1.6.4
toge Aug 15, 2023
974ef8c
update 1.7.1
toge Aug 17, 2023
8ca3d60
Merge branch 'libgit2-1.6.4' of https://github.com/toge/conan-center-…
toge Aug 17, 2023
701d719
Merge branch 'master' into libgit2-1.6.4
toge Aug 18, 2023
22a6255
libcurl version range
toge Sep 8, 2023
e34284d
zlib version range
toge Sep 8, 2023
f0658aa
Fix zlib range version
uilianries Sep 8, 2023
fed112b
Fix libcurl range version
uilianries Sep 8, 2023
37a3dc7
Merge branch 'master' into libgit2-1.6.4
toge Sep 14, 2023
45b0b17
Add zlib range to 0.28.x branch
AbrilRBS Oct 19, 2023
7aa9087
Merge branch 'master' into libgit2-1.6.4
toge Jan 9, 2024
70afd59
Merge branch 'master' into libgit2-1.6.4
toge Jan 10, 2024
f181d53
Merge branch 'master' into libgit2-1.6.4
toge Jan 12, 2024
15b732d
Merge branch 'master' into libgit2-1.6.4
toge Jan 13, 2024
6ccaf17
Merge branch 'master' into libgit2-1.6.4
toge Jan 21, 2024
51bbd22
update 1.7.2
toge Feb 9, 2024
592eb96
remove versions in config.yml
toge Feb 9, 2024
c75ed03
revert
toge Feb 9, 2024
d3e80d1
Merge branch 'master' into libgit2-1.6.4
toge Feb 11, 2024
09f2eb5
Merge branch 'master' into libgit2-1.6.4
toge Feb 16, 2024
33f0fcb
Remove 0.X releases
AbrilRBS Apr 29, 2024
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
7 changes: 0 additions & 7 deletions recipes/libgit2/0.27.x/CMakeLists.txt

This file was deleted.

5 changes: 5 additions & 0 deletions recipes/libgit2/0.27.x/conandata.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the 0.27 recipe can be dropped altogether.

Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ sources:
"0.27.10":
url: "https://github.com/libgit2/libgit2/archive/v0.27.10.tar.gz"
sha256: "f6fd26378ff71bd7a4b17b576c82c774a2e9c2d6b74b24718a8fb29551e1c4a5"
patches:
"0.27.10":
- patch_file: "patches/0.27.10-0001-fix-cmake.patch"
patch_description: "correct the order of cmake min and project, use cci's package"
patch_type: "conan"
100 changes: 42 additions & 58 deletions recipes/libgit2/0.27.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
from conans import ConanFile, tools, CMake
from conans.errors import ConanInvalidConfiguration
import functools
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.microsoft import is_msvc_static_runtime, is_msvc
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.apple import is_apple_os
import os

required_conan_version = ">=1.45.0"

required_conan_version = ">=1.53.0"


class LibGit2Conan(ConanFile):
Expand Down Expand Up @@ -38,43 +41,42 @@ class LibGit2Conan(ConanFile):
"with_sha1": "collisiondetection",
}

exports_sources = "CMakeLists.txt"
generators = "cmake", "cmake_find_package"

@property
def _source_subfolder(self):
return "source_subfolder"
def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

if not tools.is_apple_os(self.settings.os):
if not is_apple_os(self):
del self.options.with_iconv

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.cppstd
del self.settings.compiler.libcxx
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")

def layout(self):
cmake_layout(self, src_folder="src")

@property
def _need_openssl(self):
return "openssl" in (self.options.with_https, self.options.with_sha1)

def requirements(self):
self.requires("zlib/1.2.12")
self.requires("zlib/[>=1.2.12 <2]")
self.requires("http_parser/2.9.4")
if self.options.with_libssh2:
self.requires("libssh2/1.10.0")
self.requires("libssh2/1.11.0")
if self.settings.os != "Windows":
self.requires("libcurl/7.83.1")
self.requires("libcurl/[>=7.83 <9]")
if self._need_openssl:
self.requires("openssl/1.1.1o")
self.requires("openssl/[>=1.1 <4]")

def validate(self):
if self.options.with_https == "security":
if not tools.is_apple_os(self.settings.os):
if not is_apple_os(self):
raise ConanInvalidConfiguration("security is only valid for Apple products")
elif self.options.with_https == "winhttp":
if self.settings.os != "Windows":
Expand All @@ -85,8 +87,7 @@ def validate(self):
raise ConanInvalidConfiguration("win32 is only valid on Windows")

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

_cmake_https = {
"openssl": "OpenSSL",
Expand All @@ -103,49 +104,32 @@ def source(self):
"win32": "Win32",
}

@functools.lru_cache(1)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["THREADSAFE"] = self.options.threadsafe
cmake.definitions["USE_SSH"] = self.options.with_libssh2

cmake.definitions["USE_ICONV"] = self.options.get_safe("with_iconv", False)

cmake.definitions["USE_HTTPS"] = self._cmake_https[str(self.options.with_https)]
cmake.definitions["SHA1_BACKEND"] = self._cmake_sha1[str(self.options.with_sha1)]

cmake.definitions["BUILD_CLAR"] = False
cmake.definitions["BUILD_EXAMPLES"] = False

def generate(self):
tc = CMakeToolchain(self)
tc.variables["THREADSAFE"] = self.options.threadsafe
tc.variables["USE_SSH"] = self.options.with_libssh2
tc.variables["USE_ICONV"] = self.options.get_safe("with_iconv", False)
tc.variables["USE_HTTPS"] = self._cmake_https[str(self.options.with_https)]
tc.variables["SHA1_BACKEND"] = self._cmake_sha1[str(self.options.with_sha1)]
tc.variables["BUILD_CLAR"] = False
tc.variables["BUILD_EXAMPLES"] = False
if is_msvc(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to set CMP0077 to NEW for tc.variables.

cmake.definitions["STATIC_CRT"] = is_msvc_static_runtime(self)

cmake.configure()
return cmake

def _patch_sources(self):
tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"),
"FIND_PKGLIBRARIES(LIBSSH2 libssh2)",
"FIND_PACKAGE(Libssh2 REQUIRED)\n"
"\tSET(LIBSSH2_FOUND ON)\n"
"\tSET(LIBSSH2_INCLUDE_DIRS ${Libssh2_INCLUDE_DIRS})\n"
"\tSET(LIBSSH2_LIBRARIES ${Libssh2_LIBRARIES})\n"
"\tSET(LIBSSH2_LIBRARY_DIRS ${Libssh2_LIB_DIRS})")

tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"),
"FIND_PKGLIBRARIES(CURL libcurl)",
"FIND_PACKAGE(CURL REQUIRED)\n")
tc.variables["STATIC_CRT"] = is_msvc_static_runtime(self)
tc.generate()
deps = CMakeDeps(self)
deps.generate()

def build(self):
self._patch_sources()
cmake = self._configure_cmake()
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
self.copy("COPYING", src=self._source_subfolder, dst="licenses")
cmake = self._configure_cmake()
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))

def package_info(self):
self.cpp_info.set_property("pkg_config_name", "libgit2")
Expand Down
52 changes: 52 additions & 0 deletions recipes/libgit2/0.27.x/patches/0.27.10-0001-fix-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 83898c5..bc7934e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,8 +11,8 @@
# Install:
# > cmake --build . --target install

-PROJECT(libgit2 C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
+PROJECT(libgit2 C)
CMAKE_POLICY(SET CMP0015 NEW)
IF (POLICY CMP0051)
CMAKE_POLICY(SET CMP0051 NEW)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2080933..8b310fa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -126,7 +126,7 @@ IF (WIN32 AND WINHTTP)
LIST(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
ELSE ()
IF (CURL)
- FIND_PKGLIBRARIES(CURL libcurl)
+ FIND_PACKAGE(CURL REQUIRED)
ENDIF ()
IF (CURL_FOUND)
SET(GIT_CURL 1)
@@ -287,7 +287,11 @@ ENDIF()

# Optional external dependency: libssh2
IF (USE_SSH)
- FIND_PKGLIBRARIES(LIBSSH2 libssh2)
+ FIND_PACKAGE(Libssh2 REQUIRED)
+ SET(LIBSSH2_FOUND ON)
+ SET(LIBSSH2_INCLUDE_DIRS ${Libssh2_INCLUDE_DIRS})
+ SET(LIBSSH2_LIBRARIES ${Libssh2_LIBRARIES})
+ SET(LIBSSH2_LIBRARY_DIRS ${Libssh2_LIB_DIRS})
ENDIF()
IF (LIBSSH2_FOUND)
SET(GIT_SSH 1)
@@ -295,10 +299,7 @@ IF (LIBSSH2_FOUND)
LIST(APPEND LIBGIT2_LIBS ${LIBSSH2_LIBRARIES})
LIST(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})

- CHECK_LIBRARY_EXISTS("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
- IF (HAVE_LIBSSH2_MEMORY_CREDENTIALS)
- SET(GIT_SSH_MEMORY_CREDENTIALS 1)
- ENDIF()
+ SET(GIT_SSH_MEMORY_CREDENTIALS 1)
ELSE()
MESSAGE(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
ENDIF()
7 changes: 2 additions & 5 deletions recipes/libgit2/0.27.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
project(test_package LANGUAGES C)

find_package(libgit2 REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} libgit2::libgit2)
target_link_libraries(${PROJECT_NAME} PRIVATE libgit2::libgit2)
20 changes: 14 additions & 6 deletions recipes/libgit2/0.27.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
from conans import ConanFile, CMake, tools
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
7 changes: 0 additions & 7 deletions recipes/libgit2/0.28.x/CMakeLists.txt

This file was deleted.

5 changes: 5 additions & 0 deletions recipes/libgit2/0.28.x/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ sources:
"0.28.5":
url: "https://github.com/libgit2/libgit2/archive/v0.28.5.tar.gz"
sha256: "2b7b68aee6f123bc84cc502a9c12738435b8054e7d628962e091cd2a25be4f42"
patches:
"0.28.5":
- patch_file: "patches/0.28.5-0001-fix-cmake.patch"
patch_description: "correct the order of cmake min and project, use cci's package"
patch_type: "conan"
Loading
Loading