diff --git a/recipes/libgit2/0.27.x/CMakeLists.txt b/recipes/libgit2/0.27.x/CMakeLists.txt deleted file mode 100644 index c502da172e7b8..0000000000000 --- a/recipes/libgit2/0.27.x/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper C) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory(source_subfolder) diff --git a/recipes/libgit2/0.27.x/conandata.yml b/recipes/libgit2/0.27.x/conandata.yml deleted file mode 100644 index dddcd1d95b8f4..0000000000000 --- a/recipes/libgit2/0.27.x/conandata.yml +++ /dev/null @@ -1,4 +0,0 @@ -sources: - "0.27.10": - url: "https://github.com/libgit2/libgit2/archive/v0.27.10.tar.gz" - sha256: "f6fd26378ff71bd7a4b17b576c82c774a2e9c2d6b74b24718a8fb29551e1c4a5" diff --git a/recipes/libgit2/0.27.x/conanfile.py b/recipes/libgit2/0.27.x/conanfile.py deleted file mode 100644 index 07e2765904500..0000000000000 --- a/recipes/libgit2/0.27.x/conanfile.py +++ /dev/null @@ -1,156 +0,0 @@ -from conan.tools.microsoft import is_msvc, is_msvc_static_runtime -from conans import ConanFile, tools, CMake -from conans.errors import ConanInvalidConfiguration -import functools -import os - -required_conan_version = ">=1.45.0" - - -class LibGit2Conan(ConanFile): - name = "libgit2" - description = ( - "libgit2 is a portable, pure C implementation of the Git core methods " - "provided as a re-entrant linkable library with a solid API" - ) - topics = ("libgit2", "git", "scm") - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://libgit2.org/" - license = "GPL-2.0-linking-exception" - - settings = "os", "arch", "compiler", "build_type" - options = { - "shared": [True, False], - "fPIC": [True, False], - "threadsafe": [True, False], - "with_iconv": [True, False], - "with_libssh2": [True, False], - "with_https": [False, "openssl", "winhttp", "security"], - "with_sha1": ["collisiondetection", "commoncrypto", "openssl", "generic", "win32"], - } - default_options = { - "shared": False, - "fPIC": True, - "threadsafe": True, - "with_iconv": False, - "with_libssh2": True, - "with_https": "openssl", - "with_sha1": "collisiondetection", - } - - exports_sources = "CMakeLists.txt" - generators = "cmake", "cmake_find_package" - - @property - def _source_subfolder(self): - return "source_subfolder" - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - if not tools.is_apple_os(self.settings.os): - 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 - - @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("http_parser/2.9.4") - if self.options.with_libssh2: - self.requires("libssh2/1.10.0") - if self.settings.os != "Windows": - self.requires("libcurl/7.83.1") - if self._need_openssl: - self.requires("openssl/1.1.1o") - - def validate(self): - if self.options.with_https == "security": - if not tools.is_apple_os(self.settings.os): - raise ConanInvalidConfiguration("security is only valid for Apple products") - elif self.options.with_https == "winhttp": - if self.settings.os != "Windows": - raise ConanInvalidConfiguration("winhttp is only valid on Windows") - - if self.options.with_sha1 == "win32": - if self.settings.os != "Windows": - 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) - - _cmake_https = { - "openssl": "OpenSSL", - "winhttp": "WinHTTP", - "security": "SecureTransport", - False: "OFF", - } - - _cmake_sha1 = { - "collisiondetection": "CollisionDetection", - "commoncrypto": "CommonCrypto", - "openssl": "OpenSSL", - "generic": "Generic", - "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 - - if is_msvc(self): - 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") - - def build(self): - self._patch_sources() - cmake = self._configure_cmake() - cmake.build() - - def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() - cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - - def package_info(self): - self.cpp_info.set_property("pkg_config_name", "libgit2") - self.cpp_info.libs = ["git2"] - if self.settings.os == "Windows": - self.cpp_info.system_libs.extend(["winhttp", "rpcrt4", "crypt32"]) - if self.settings.os in ["Linux", "FreeBSD"] and self.options.threadsafe: - self.cpp_info.system_libs.append("pthread") diff --git a/recipes/libgit2/0.27.x/test_package/CMakeLists.txt b/recipes/libgit2/0.27.x/test_package/CMakeLists.txt deleted file mode 100644 index 912bdc647f324..0000000000000 --- a/recipes/libgit2/0.27.x/test_package/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(libgit2 REQUIRED CONFIG) - -add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} libgit2::libgit2) diff --git a/recipes/libgit2/0.27.x/test_package/conanfile.py b/recipes/libgit2/0.27.x/test_package/conanfile.py deleted file mode 100644 index 38f4483872d47..0000000000000 --- a/recipes/libgit2/0.27.x/test_package/conanfile.py +++ /dev/null @@ -1,17 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" - - 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) diff --git a/recipes/libgit2/0.27.x/test_package/test_package.c b/recipes/libgit2/0.27.x/test_package/test_package.c deleted file mode 100644 index 1ea125101cdc8..0000000000000 --- a/recipes/libgit2/0.27.x/test_package/test_package.c +++ /dev/null @@ -1,34 +0,0 @@ -#include - -#include - -int main() -{ - git_libgit2_init(); - int versionMajor, versionMinor, versionRev; - git_libgit2_version(&versionMajor, &versionMinor, &versionRev); - - printf("libgit2 v%i.%i.%i\n", versionMajor, versionMinor, versionRev); - - printf("Compile Features:\n"); - - int features = git_libgit2_features(); - - if (features & GIT_FEATURE_THREADS) - printf(" - Thread safe\n"); - else - printf(" - Single thread only\n"); - - if (features & GIT_FEATURE_HTTPS) - printf(" - TLS (openssl, winhttp or security)\n"); - else - printf(" - No TLS\n"); - - if (features & GIT_FEATURE_SSH) - printf(" - SSH (libssh2)\n"); - else - printf(" - No SSH support\n"); - - git_libgit2_shutdown(); - return 0; -} diff --git a/recipes/libgit2/0.28.x/CMakeLists.txt b/recipes/libgit2/0.28.x/CMakeLists.txt deleted file mode 100644 index c502da172e7b8..0000000000000 --- a/recipes/libgit2/0.28.x/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper C) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory(source_subfolder) diff --git a/recipes/libgit2/0.28.x/conandata.yml b/recipes/libgit2/0.28.x/conandata.yml deleted file mode 100644 index 25994eed756a3..0000000000000 --- a/recipes/libgit2/0.28.x/conandata.yml +++ /dev/null @@ -1,4 +0,0 @@ -sources: - "0.28.5": - url: "https://github.com/libgit2/libgit2/archive/v0.28.5.tar.gz" - sha256: "2b7b68aee6f123bc84cc502a9c12738435b8054e7d628962e091cd2a25be4f42" diff --git a/recipes/libgit2/0.28.x/conanfile.py b/recipes/libgit2/0.28.x/conanfile.py deleted file mode 100644 index 7e3da960a3cb2..0000000000000 --- a/recipes/libgit2/0.28.x/conanfile.py +++ /dev/null @@ -1,160 +0,0 @@ -from conan.tools.microsoft import is_msvc, is_msvc_static_runtime -from conans import ConanFile, tools, CMake -from conans.errors import ConanInvalidConfiguration -import functools -import os - -required_conan_version = ">=1.45.0" - - -class LibGit2Conan(ConanFile): - name = "libgit2" - description = ( - "libgit2 is a portable, pure C implementation of the Git core methods " - "provided as a re-entrant linkable library with a solid API" - ) - topics = ("libgit2", "git", "scm") - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://libgit2.org/" - license = "GPL-2.0-linking-exception" - - settings = "os", "arch", "compiler", "build_type" - options = { - "shared": [True, False], - "fPIC": [True, False], - "threadsafe": [True, False], - "with_iconv": [True, False], - "with_libssh2": [True, False], - "with_https": [False, "openssl", "mbedtls", "winhttp", "security"], - "with_sha1": ["collisiondetection", "commoncrypto", "openssl", "mbedtls", "generic", "win32"], - } - default_options = { - "shared": False, - "fPIC": True, - "threadsafe": True, - "with_iconv": False, - "with_libssh2": True, - "with_https": "openssl", - "with_sha1": "collisiondetection", - } - - exports_sources = "CMakeLists.txt" - generators = "cmake", "cmake_find_package" - - @property - def _source_subfolder(self): - return "source_subfolder" - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - if not tools.is_apple_os(self.settings.os): - 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 - - @property - def _need_openssl(self): - return "openssl" in (self.options.with_https, self.options.with_sha1) - - @property - def _need_mbedtls(self): - return "mbedtls" in (self.options.with_https, self.options.with_sha1) - - def requirements(self): - self.requires("zlib/1.2.12") - self.requires("http_parser/2.9.4") - if self.options.with_libssh2: - self.requires("libssh2/1.10.0") - if self._need_openssl: - self.requires("openssl/1.1.1o") - if self._need_mbedtls: - self.requires("mbedtls/3.1.0") - if tools.is_apple_os(self.settings.os) and self.options.with_iconv: - self.requires("libiconv/1.16") - - def validate(self): - if self.options.with_https == "security": - if not tools.is_apple_os(self.settings.os): - raise ConanInvalidConfiguration("security is only valid for Apple products") - elif self.options.with_https == "winhttp": - if self.settings.os != "Windows": - raise ConanInvalidConfiguration("winhttp is only valid on Windows") - - if self.options.with_sha1 == "win32": - if self.settings.os != "Windows": - 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) - - _cmake_https = { - "openssl": "OpenSSL", - "winhttp": "WinHTTP", - "security": "SecureTransport", - "mbedtls": "mbedTLS", - False: "OFF", - } - - _cmake_sha1 = { - "collisiondetection": "CollisionDetection", - "commoncrypto": "CommonCrypto", - "openssl": "OpenSSL", - "mbedtls": "mbedTLS", - "generic": "Generic", - "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 - - if is_msvc(self): - 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})") - - def build(self): - self._patch_sources() - cmake = self._configure_cmake() - cmake.build() - - def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() - cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - - def package_info(self): - self.cpp_info.set_property("pkg_config_name", "libgit2") - self.cpp_info.libs = ["git2"] - if self.settings.os == "Windows": - self.cpp_info.system_libs.extend(["winhttp", "rpcrt4", "crypt32"]) - if self.settings.os in ["Linux", "FreeBSD"] and self.options.threadsafe: - self.cpp_info.system_libs.append("pthread") diff --git a/recipes/libgit2/0.28.x/test_package/CMakeLists.txt b/recipes/libgit2/0.28.x/test_package/CMakeLists.txt deleted file mode 100644 index 912bdc647f324..0000000000000 --- a/recipes/libgit2/0.28.x/test_package/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(libgit2 REQUIRED CONFIG) - -add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} libgit2::libgit2) diff --git a/recipes/libgit2/0.28.x/test_package/conanfile.py b/recipes/libgit2/0.28.x/test_package/conanfile.py deleted file mode 100644 index 38f4483872d47..0000000000000 --- a/recipes/libgit2/0.28.x/test_package/conanfile.py +++ /dev/null @@ -1,17 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" - - 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) diff --git a/recipes/libgit2/0.28.x/test_package/test_package.c b/recipes/libgit2/0.28.x/test_package/test_package.c deleted file mode 100644 index 96e8eda89c73b..0000000000000 --- a/recipes/libgit2/0.28.x/test_package/test_package.c +++ /dev/null @@ -1,34 +0,0 @@ -#include - -#include - -int main() -{ - git_libgit2_init(); - int versionMajor, versionMinor, versionRev; - git_libgit2_version(&versionMajor, &versionMinor, &versionRev); - - printf("libgit2 v%i.%i.%i\n", versionMajor, versionMinor, versionRev); - - printf("Compile Features:\n"); - - int features = git_libgit2_features(); - - if (features & GIT_FEATURE_THREADS) - printf(" - Thread safe\n"); - else - printf(" - Single thread only\n"); - - if (features & GIT_FEATURE_HTTPS) - printf(" - TLS (openssl, mbedtls, winhttp or security)\n"); - else - printf(" - No TLS\n"); - - if (features & GIT_FEATURE_SSH) - printf(" - SSH (libssh2)\n"); - else - printf(" - No SSH support\n"); - - git_libgit2_shutdown(); - return 0; -} diff --git a/recipes/libgit2/all/CMakeLists.txt b/recipes/libgit2/all/CMakeLists.txt deleted file mode 100644 index c502da172e7b8..0000000000000 --- a/recipes/libgit2/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper C) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory(source_subfolder) diff --git a/recipes/libgit2/all/conandata.yml b/recipes/libgit2/all/conandata.yml index 7725b775b39de..eb55dd0e9e7c5 100644 --- a/recipes/libgit2/all/conandata.yml +++ b/recipes/libgit2/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.7.2": + url: "https://github.com/libgit2/libgit2/archive/v1.7.2.tar.gz" + sha256: "de384e29d7efc9330c6cdb126ebf88342b5025d920dcb7c645defad85195ea7f" "1.5.0": url: "https://github.com/libgit2/libgit2/archive/v1.5.0.tar.gz" sha256: "8de872a0f201b33d9522b817c92e14edb4efad18dae95cf156cf240b2efff93e" @@ -18,21 +21,31 @@ sources: url: "https://github.com/libgit2/libgit2/archive/v1.0.1.tar.gz" sha256: "1775427a6098f441ddbaa5bd4e9b8a043c7401e450ed761e69a415530fea81d2" patches: + "1.7.2": + - patch_file: "patches/1.7.2-0001-fix-cmake.patch" + patch_description: "use cci's packages" + patch_type: "conan" "1.5.0": - patch_file: "patches/1.4.3-0001-fix-cmake.patch" - base_path: "source_subfolder" + patch_description: "use cci's packages" + patch_type: "conan" "1.4.3": - patch_file: "patches/1.4.3-0001-fix-cmake.patch" - base_path: "source_subfolder" + patch_description: "use cci's packages" + patch_type: "conan" "1.3.0": - patch_file: "patches/1.3.0-0001-fix-cmake.patch" - base_path: "source_subfolder" + patch_description: "use cci's packages" + patch_type: "conan" "1.2.0": - patch_file: "patches/1.2.0-0001-fix-cmake.patch" - base_path: "source_subfolder" + patch_description: "use cci's packages" + patch_type: "conan" "1.1.1": - patch_file: "patches/1.1.1-0001-fix-cmake.patch" - base_path: "source_subfolder" + patch_description: "use cci's packages" + patch_type: "conan" "1.0.1": - patch_file: "patches/1.0.1-0001-fix-cmake.patch" - base_path: "source_subfolder" + patch_description: "use cci's packages" + patch_type: "conan" diff --git a/recipes/libgit2/all/conanfile.py b/recipes/libgit2/all/conanfile.py index c042b13f51df6..272361d4c2013 100644 --- a/recipes/libgit2/all/conanfile.py +++ b/recipes/libgit2/all/conanfile.py @@ -1,10 +1,14 @@ -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.scm import Version +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): @@ -13,11 +17,11 @@ class LibGit2Conan(ConanFile): "libgit2 is a portable, pure C implementation of the Git core methods " "provided as a re-entrant linkable library with a solid API" ) - topics = ("libgit2", "git", "scm") + license = "GPL-2.0-linking-exception" url = "https://github.com/conan-io/conan-center-index" homepage = "https://libgit2.org/" - license = "GPL-2.0-linking-exception" - + topics = ("git", "scm") + package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -41,22 +45,15 @@ class LibGit2Conan(ConanFile): "with_ntlmclient": True, "with_regex": "builtin", } - generators = "cmake", "cmake_find_package" - - @property - def _source_subfolder(self): - return "source_subfolder" def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + 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 if self.settings.os == "Windows": @@ -67,25 +64,28 @@ def config_options(self): 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") def requirements(self): - self.requires("zlib/1.2.12") + self.requires("zlib/[>=1.2.11 <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._need_openssl: - self.requires("openssl/1.1.1o") + self.requires("openssl/[>=1.1 <4]") if self._need_mbedtls: - self.requires("mbedtls/3.1.0") + self.requires("mbedtls/3.2.1") if self.options.get_safe("with_iconv"): - self.requires("libiconv/1.16") + self.requires("libiconv/1.17") if self.options.with_regex == "pcre": self.requires("pcre/8.45") elif self.options.with_regex == "pcre2": - self.requires("pcre2/10.40") + self.requires("pcre2/10.42") @property def _need_openssl(self): @@ -97,7 +97,7 @@ def _need_mbedtls(self): 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": @@ -108,22 +108,21 @@ def validate(self): raise ConanInvalidConfiguration("win32 is only valid on Windows") if self.options.with_regex == "regcomp" or self.options.with_regex == "regcomp_l": - if self.settings.compiler == "Visual Studio": + if is_msvc(self): raise ConanInvalidConfiguration("{} isn't supported by Visual Studio".format(self.options.with_regex)) if self.settings.os in ["iOS", "tvOS", "watchOS"] and self.options.with_regex == "regcomp_l": raise ConanInvalidConfiguration("regcomp_l isn't supported on {}".format(self.settings.os)) 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", "winhttp": "WinHTTP", "security": "SecureTransport", "mbedtls": "mbedTLS", - False: "OFF", + "False": "OFF", } _cmake_sha1 = { @@ -133,49 +132,49 @@ def source(self): "mbedtls": "mbedTLS", "generic": "Generic", "win32": "Win32", + "False": "OFF", } - @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["USE_SHA1"] = self._cmake_sha1[str(self.options.with_sha1)] - - if tools.Version(self.version) >= "1.4.0": - cmake.definitions["BUILD_TESTS"] = False - cmake.definitions["BUILD_CLAR"] = False - cmake.definitions["BUILD_EXAMPLES"] = False - cmake.definitions["USE_HTTP_PARSER"] = "system" - - cmake.definitions["REGEX_BACKEND"] = self.options.with_regex - + 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["USE_SHA1"] = self._cmake_sha1[str(self.options.with_sha1)] + if Version(self.version) >= "1.4.0": + tc.variables["BUILD_TESTS"] = False + tc.variables["BUILD_CLAR"] = False + tc.variables["BUILD_CLI"] = False + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["USE_HTTP_PARSER"] = "system" + tc.variables["REGEX_BACKEND"] = self.options.with_regex if is_msvc(self): - cmake.definitions["STATIC_CRT"] = is_msvc_static_runtime(self) - - cmake.configure() - return cmake + tc.variables["STATIC_CRT"] = is_msvc_static_runtime(self) + # REGEX_BACKEND is SET(), avoid options overriding it + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - 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") self.cpp_info.libs = ["git2"] if self.settings.os == "Windows": self.cpp_info.system_libs.extend(["winhttp", "rpcrt4", "crypt32"]) + if Version(self.version) >= "1.7.0": + self.cpp_info.system_libs.append("secur32") if self.settings.os in ["Linux", "FreeBSD"] and self.options.threadsafe: self.cpp_info.system_libs.append("pthread") diff --git a/recipes/libgit2/all/patches/1.0.1-0001-fix-cmake.patch b/recipes/libgit2/all/patches/1.0.1-0001-fix-cmake.patch index 2f0d05b998d5d..3c23186ba4771 100644 --- a/recipes/libgit2/all/patches/1.0.1-0001-fix-cmake.patch +++ b/recipes/libgit2/all/patches/1.0.1-0001-fix-cmake.patch @@ -1,5 +1,19 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8264158..374a21c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -11,8 +11,8 @@ + # Install: + # > cmake --build . --target install + +-PROJECT(libgit2 C) + CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) ++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 dff1d94..abd9c45 100644 +index dff1d94..25652b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -158,11 +158,11 @@ ENDIF() @@ -31,3 +45,15 @@ index dff1d94..abd9c45 100644 ENDIF() IF (LIBSSH2_FOUND) SET(GIT_SSH 1) +@@ -209,10 +213,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() diff --git a/recipes/libgit2/all/patches/1.1.1-0001-fix-cmake.patch b/recipes/libgit2/all/patches/1.1.1-0001-fix-cmake.patch index 5dc56b1a31b92..3abde1ad5528a 100644 --- a/recipes/libgit2/all/patches/1.1.1-0001-fix-cmake.patch +++ b/recipes/libgit2/all/patches/1.1.1-0001-fix-cmake.patch @@ -1,5 +1,5 @@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index d01cc64..0941cbd 100644 +index d01cc64..5691f7e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -167,11 +167,11 @@ ENDIF() @@ -31,3 +31,15 @@ index d01cc64..0941cbd 100644 ENDIF() IF (LIBSSH2_FOUND) SET(GIT_SSH 1) +@@ -218,10 +222,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() diff --git a/recipes/libgit2/all/patches/1.2.0-0001-fix-cmake.patch b/recipes/libgit2/all/patches/1.2.0-0001-fix-cmake.patch index 0fbbd568d7b10..950bd6ff11e0a 100644 --- a/recipes/libgit2/all/patches/1.2.0-0001-fix-cmake.patch +++ b/recipes/libgit2/all/patches/1.2.0-0001-fix-cmake.patch @@ -1,5 +1,5 @@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 45dec27..783c657 100644 +index 45dec27..d7652f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -178,11 +178,11 @@ ENDIF() @@ -31,3 +31,15 @@ index 45dec27..783c657 100644 ENDIF() IF (LIBSSH2_FOUND) SET(GIT_SSH 1) +@@ -239,10 +243,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() diff --git a/recipes/libgit2/all/patches/1.3.0-0001-fix-cmake.patch b/recipes/libgit2/all/patches/1.3.0-0001-fix-cmake.patch index 997b6dd7759b0..34d77da78eff1 100644 --- a/recipes/libgit2/all/patches/1.3.0-0001-fix-cmake.patch +++ b/recipes/libgit2/all/patches/1.3.0-0001-fix-cmake.patch @@ -1,5 +1,5 @@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index fdb3673..783c657 100644 +index fdb3673..d7652f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -178,11 +178,11 @@ ENDIF() @@ -38,3 +38,15 @@ index fdb3673..783c657 100644 ENDIF() IF (LIBSSH2_FOUND) SET(GIT_SSH 1) +@@ -246,10 +243,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() diff --git a/recipes/libgit2/all/patches/1.4.3-0001-fix-cmake.patch b/recipes/libgit2/all/patches/1.4.3-0001-fix-cmake.patch index 459414c1a9584..66a17f3f7e869 100644 --- a/recipes/libgit2/all/patches/1.4.3-0001-fix-cmake.patch +++ b/recipes/libgit2/all/patches/1.4.3-0001-fix-cmake.patch @@ -18,7 +18,7 @@ index 955aea3..ff94eb8 100644 add_feature_info(http-parser ON "http-parser support (system)") else() diff --git a/cmake/SelectSSH.cmake b/cmake/SelectSSH.cmake -index 23dfc97..a094cc7 100644 +index 23dfc97..386f184 100644 --- a/cmake/SelectSSH.cmake +++ b/cmake/SelectSSH.cmake @@ -1,13 +1,10 @@ @@ -40,3 +40,15 @@ index 23dfc97..a094cc7 100644 if(NOT LIBSSH2_FOUND) message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.") +@@ -20,10 +17,7 @@ if(LIBSSH2_FOUND) + list(APPEND LIBGIT2_SYSTEM_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() diff --git a/recipes/libgit2/all/patches/1.7.2-0001-fix-cmake.patch b/recipes/libgit2/all/patches/1.7.2-0001-fix-cmake.patch new file mode 100644 index 0000000000000..8705249e1247a --- /dev/null +++ b/recipes/libgit2/all/patches/1.7.2-0001-fix-cmake.patch @@ -0,0 +1,70 @@ +diff --git a/cmake/SelectHTTPParser.cmake b/cmake/SelectHTTPParser.cmake +index 955aea3..ff94eb8 100644 +--- a/cmake/SelectHTTPParser.cmake ++++ b/cmake/SelectHTTPParser.cmake +@@ -1,10 +1,10 @@ + # Optional external dependency: http-parser + if(USE_HTTP_PARSER STREQUAL "system") +- find_package(HTTPParser) ++ find_package(http_parser) + +- if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2) +- list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS}) +- list(APPEND LIBGIT2_SYSTEM_LIBS ${HTTP_PARSER_LIBRARIES}) ++ if(http_parser_FOUND) ++ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${http_parser_INCLUDE_DIRS}) ++ list(APPEND LIBGIT2_SYSTEM_LIBS ${http_parser_LIBRARIES}) + list(APPEND LIBGIT2_PC_LIBS "-lhttp_parser") + add_feature_info(http-parser ON "http-parser support (system)") + else() +diff --git a/cmake/SelectHTTPSBackend.cmake b/cmake/SelectHTTPSBackend.cmake +index d149416..33473ee 100644 +--- a/cmake/SelectHTTPSBackend.cmake ++++ b/cmake/SelectHTTPSBackend.cmake +@@ -9,6 +9,11 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + endif() + + if(USE_HTTPS) ++ if(WIN32) ++ list(APPEND LIBGIT2_SYSTEM_LIBS "secur32") ++ list(APPEND LIBGIT2_PC_LIBS "-lsecur32") ++ endif() ++ + # Auto-select TLS backend + sanitizebool(USE_HTTPS) + if(USE_HTTPS STREQUAL ON) +diff --git a/cmake/SelectSSH.cmake b/cmake/SelectSSH.cmake +index 23dfc97..386f184 100644 +--- a/cmake/SelectSSH.cmake ++++ b/cmake/SelectSSH.cmake +@@ -1,13 +1,10 @@ + # Optional external dependency: libssh2 + if(USE_SSH) +- find_pkglibraries(LIBSSH2 libssh2) +- if(NOT LIBSSH2_FOUND) +- find_package(LibSSH2) +- set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR}) +- get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY) +- set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY}) +- set(LIBSSH2_LDFLAGS "-lssh2") +- endif() ++ 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}) + + if(NOT LIBSSH2_FOUND) + message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.") +@@ -20,10 +17,7 @@ if(LIBSSH2_FOUND) + list(APPEND LIBGIT2_SYSTEM_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() diff --git a/recipes/libgit2/all/test_package/CMakeLists.txt b/recipes/libgit2/all/test_package/CMakeLists.txt index 912bdc647f324..b2c8aa0ca7f27 100644 --- a/recipes/libgit2/all/test_package/CMakeLists.txt +++ b/recipes/libgit2/all/test_package/CMakeLists.txt @@ -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) diff --git a/recipes/libgit2/all/test_package/conanfile.py b/recipes/libgit2/all/test_package/conanfile.py index 38f4483872d47..ef5d7042163ec 100644 --- a/recipes/libgit2/all/test_package/conanfile.py +++ b/recipes/libgit2/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -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) @@ -12,6 +21,6 @@ def build(self): 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") diff --git a/recipes/libgit2/config.yml b/recipes/libgit2/config.yml index c472349adb3cc..9af2cc041342f 100644 --- a/recipes/libgit2/config.yml +++ b/recipes/libgit2/config.yml @@ -1,4 +1,6 @@ versions: + "1.7.2": + folder: "all" "1.5.0": folder: "all" "1.4.3": @@ -11,7 +13,3 @@ versions: folder: "all" "1.0.1": folder: "all" - "0.28.5": - folder: "0.28.x" - "0.27.10": - folder: "0.27.x"