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

QArchive: Add version 2.2.2 and modernize #14212

Merged
merged 11 commits into from
Dec 2, 2022
Merged
7 changes: 0 additions & 7 deletions recipes/qarchive/all/CMakeLists.txt

This file was deleted.

9 changes: 3 additions & 6 deletions recipes/qarchive/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"2.2.2":
url: "https://github.com/antony-jr/QArchive/archive/v2.2.2.tar.gz"
sha256: "c844f07baa7db6ea63ddffda31f84a84eab7af17399b53b990164551fa121037"
"2.1.1":
url: "https://github.com/antony-jr/QArchive/archive/v2.1.1.tar.gz"
sha256: "4ed51121a5bc9b5981d2fa3927f951a6a91ccca233d6b6dc4fef55b4ca5a2d92"
Expand All @@ -11,16 +14,10 @@ sources:
patches:
"2.1.1":
- patch_file: "patches/0001-cmake-conan-compatibility.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-export-symbols.patch"
base_path: "source_subfolder"
"2.0.2":
- patch_file: "patches/0001-cmake-conan-compatibility.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-export-symbols.patch"
base_path: "source_subfolder"
"2.0.1":
- patch_file: "patches/0001-cmake-conan-compatibility.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-export-symbols.patch"
base_path: "source_subfolder"
37 changes: 17 additions & 20 deletions recipes/qarchive/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from conan import ConanFile
from conan.tools.files import get, apply_conandata_patches, rmdir, save, export_conandata_patches
from conans import CMake
import functools
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
import os
import textwrap

Expand Down Expand Up @@ -29,14 +28,7 @@ class QarchiveConan(ConanFile):
"fPIC": True,
}

generators = "cmake", "cmake_find_package"

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

def export_sources(self):
self.copy("CMakeLists.txt")
export_conandata_patches(self)

def config_options(self):
Expand All @@ -49,29 +41,34 @@ def configure(self):

def requirements(self):
self.requires("libarchive/3.6.1")
self.requires("qt/5.15.6")
self.requires("qt/5.15.7")

def build_requirements(self):
self.build_requires("cmake/3.24.2")
self.tool_requires("cmake/3.24.2")

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

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

@functools.lru_cache(1)
def _configure_cmake(self):
cmake = CMake(self)
cmake.configure()
return cmake
def generate(self):
tc = CMakeToolchain(self)
tc.generate()

cd = CMakeDeps(self)
cd.generate()

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

def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
cmake = self._configure_cmake()
self.copy("LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
Expand Down
3 changes: 0 additions & 3 deletions recipes/qarchive/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(QArchive REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
Expand Down
21 changes: 15 additions & 6 deletions recipes/qarchive/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from conans import ConanFile, CMake, tools
import os

from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake
from conan.tools.layout import cmake_layout

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.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
11 changes: 1 addition & 10 deletions recipes/qarchive/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
#include <QCoreApplication>
#include <QArchive>

int main(int argc, char **argv)
{
using QArchive::DiskExtractor;
QCoreApplication app(argc, argv);
DiskExtractor Extractor("Test.7z");

/* Connect Signals and Slots. */
QObject::connect(&Extractor ,
&DiskExtractor::finished ,
&app ,
&QCoreApplication::quit);
QArchive::DiskExtractor Extractor("Test.7z");

Extractor.start();
Extractor.cancel();
Expand Down
13 changes: 13 additions & 0 deletions recipes/qarchive/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(QArchive REQUIRED CONFIG)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} QArchive)
# Must compile with "-fPIC" since Qt was built with -reduce-relocations.
target_compile_options(${PROJECT_NAME} PRIVATE -fPIC)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
17 changes: 17 additions & 0 deletions recipes/qarchive/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake
from conan.tools.build import cross_building
import os

class TestPackageV1Conan(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 cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
2 changes: 2 additions & 0 deletions recipes/qarchive/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"2.2.2":
folder: all
"2.1.1":
folder: all
"2.0.2":
Expand Down