Skip to content

Commit 3989cec

Browse files
ericriffuilianries
andauthored
(#14212) QArchive: Add version 2.2.2 and modernize
* Add version 2.2.1 * Simplify test package so it doesn't require Qt code * Modernize recipe and test packages * Bump qt version * Fix copy-paste error * Fix patches * Use tool_rquires instead of build_requires Co-authored-by: Uilian Ries <[email protected]> * Replace 2.2.1 with 2.2.2 * Replace 2.2.2 with 2.2.3 * Improve qt6 support * Use modern approach to query dependencies info Co-authored-by: Uilian Ries <[email protected]> Co-authored-by: Uilian Ries <[email protected]>
1 parent 54fef13 commit 3989cec

File tree

9 files changed

+72
-50
lines changed

9 files changed

+72
-50
lines changed

recipes/qarchive/all/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

recipes/qarchive/all/conandata.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
sources:
2+
"2.2.3":
3+
url: "https://github.com/antony-jr/QArchive/archive/v2.2.3.tar.gz"
4+
sha256: "2ada10efda34fe96c25744dd67e74ec68587d30ab01cc20be25cbcfb1e6262c4"
25
"2.1.1":
36
url: "https://github.com/antony-jr/QArchive/archive/v2.1.1.tar.gz"
47
sha256: "4ed51121a5bc9b5981d2fa3927f951a6a91ccca233d6b6dc4fef55b4ca5a2d92"
@@ -11,16 +14,10 @@ sources:
1114
patches:
1215
"2.1.1":
1316
- patch_file: "patches/0001-cmake-conan-compatibility.patch"
14-
base_path: "source_subfolder"
1517
- patch_file: "patches/0002-export-symbols.patch"
16-
base_path: "source_subfolder"
1718
"2.0.2":
1819
- patch_file: "patches/0001-cmake-conan-compatibility.patch"
19-
base_path: "source_subfolder"
2020
- patch_file: "patches/0002-export-symbols.patch"
21-
base_path: "source_subfolder"
2221
"2.0.1":
2322
- patch_file: "patches/0001-cmake-conan-compatibility.patch"
24-
base_path: "source_subfolder"
2523
- patch_file: "patches/0002-export-symbols.patch"
26-
base_path: "source_subfolder"

recipes/qarchive/all/conanfile.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from conan import ConanFile
22
from conan.tools.files import get, apply_conandata_patches, rmdir, save, export_conandata_patches
3-
from conans import CMake
4-
import functools
3+
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
4+
from conan.tools.scm import Version
55
import os
66
import textwrap
77

@@ -29,14 +29,11 @@ class QarchiveConan(ConanFile):
2929
"fPIC": True,
3030
}
3131

32-
generators = "cmake", "cmake_find_package"
33-
3432
@property
35-
def _source_subfolder(self):
36-
return "source_subfolder"
33+
def _qt_major(self):
34+
return Version(self.dependencies["qt"].ref.version).major
3735

3836
def export_sources(self):
39-
self.copy("CMakeLists.txt")
4037
export_conandata_patches(self)
4138

4239
def config_options(self):
@@ -49,29 +46,35 @@ def configure(self):
4946

5047
def requirements(self):
5148
self.requires("libarchive/3.6.1")
52-
self.requires("qt/5.15.6")
49+
self.requires("qt/5.15.7")
5350

5451
def build_requirements(self):
55-
self.build_requires("cmake/3.24.2")
52+
self.tool_requires("cmake/3.24.2")
53+
54+
def layout(self):
55+
cmake_layout(self, src_folder="src")
5656

5757
def source(self):
5858
get(self, **self.conan_data["sources"][self.version],
59-
destination=self._source_subfolder, strip_root=True)
59+
destination=self.source_folder, strip_root=True)
6060

61-
@functools.lru_cache(1)
62-
def _configure_cmake(self):
63-
cmake = CMake(self)
64-
cmake.configure()
65-
return cmake
61+
def generate(self):
62+
tc = CMakeToolchain(self)
63+
tc.variables["QARCHIVE_QT_VERSION_MAJOR"] = self._qt_major
64+
tc.generate()
65+
66+
cd = CMakeDeps(self)
67+
cd.generate()
6668

6769
def build(self):
6870
apply_conandata_patches(self)
69-
cmake = self._configure_cmake()
71+
cmake = CMake(self)
72+
cmake.configure()
7073
cmake.build()
7174

7275
def package(self):
73-
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
74-
cmake = self._configure_cmake()
76+
self.copy("LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
77+
cmake = CMake(self)
7578
cmake.install()
7679
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
7780
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))

recipes/qarchive/all/test_package/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
cmake_minimum_required(VERSION 3.1)
22
project(test_package CXX)
33

4-
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5-
conan_basic_setup(TARGETS)
6-
74
find_package(QArchive REQUIRED CONFIG)
85

96
add_executable(${PROJECT_NAME} test_package.cpp)
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
from conans import ConanFile, CMake, tools
21
import os
3-
2+
from conan import ConanFile
3+
from conan.tools.build import can_run
4+
from conan.tools.cmake import CMake
5+
from conan.tools.layout import cmake_layout
46

57
class TestPackageConan(ConanFile):
68
settings = "os", "arch", "compiler", "build_type"
7-
generators = "cmake", "cmake_find_package_multi"
9+
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
10+
test_type = "explicit"
11+
12+
def requirements(self):
13+
self.requires(self.tested_reference_str)
14+
15+
def layout(self):
16+
cmake_layout(self)
817

918
def build(self):
1019
cmake = CMake(self)
1120
cmake.configure()
1221
cmake.build()
1322

1423
def test(self):
15-
if not tools.cross_building(self):
16-
bin_path = os.path.join("bin", "test_package")
17-
self.run(bin_path, run_environment=True)
24+
if can_run(self):
25+
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
26+
self.run(bin_path, env="conanrun")

recipes/qarchive/all/test_package/test_package.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
#include <QCoreApplication>
21
#include <QArchive>
32

43
int main(int argc, char **argv)
54
{
6-
using QArchive::DiskExtractor;
7-
QCoreApplication app(argc, argv);
8-
DiskExtractor Extractor("Test.7z");
9-
10-
/* Connect Signals and Slots. */
11-
QObject::connect(&Extractor ,
12-
&DiskExtractor::finished ,
13-
&app ,
14-
&QCoreApplication::quit);
5+
QArchive::DiskExtractor Extractor("Test.7z");
156

167
Extractor.start();
178
Extractor.cancel();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(test_package CXX)
3+
4+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5+
conan_basic_setup(TARGETS)
6+
7+
find_package(QArchive REQUIRED CONFIG)
8+
9+
add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
10+
target_link_libraries(${PROJECT_NAME} QArchive)
11+
# Must compile with "-fPIC" since Qt was built with -reduce-relocations.
12+
target_compile_options(${PROJECT_NAME} PRIVATE -fPIC)
13+
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from conans import ConanFile, CMake
2+
from conan.tools.build import cross_building
3+
import os
4+
5+
class TestPackageV1Conan(ConanFile):
6+
settings = "os", "arch", "compiler", "build_type"
7+
generators = "cmake", "cmake_find_package_multi"
8+
9+
def build(self):
10+
cmake = CMake(self)
11+
cmake.configure()
12+
cmake.build()
13+
14+
def test(self):
15+
if not cross_building(self):
16+
bin_path = os.path.join("bin", "test_package")
17+
self.run(bin_path, run_environment=True)

recipes/qarchive/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
versions:
2+
"2.2.3":
3+
folder: all
24
"2.1.1":
35
folder: all
46
"2.0.2":

0 commit comments

Comments
 (0)