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

Qcoro 0.8.0 with conan 2 support #17183

Closed
Closed
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
7 changes: 0 additions & 7 deletions recipes/qcoro/all/CMakeLists.txt

This file was deleted.

7 changes: 7 additions & 0 deletions recipes/qcoro/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ sources:
"0.4.0":
url: "https://github.com/danvratil/qcoro/archive/refs/tags/v0.4.0.tar.gz"
sha256: "0e68b3f0ce7bf521ffbdd731464d2d60d8d7a39a749b551ed26855a1707d86d1"
"0.8.0":
url: "https://github.com/danvratil/qcoro/archive/refs/tags/v0.8.0.tar.gz"
sha256: "28F90D817F42352084242F7A1FF090C5CFF92359E4DBECEA8F04D39EBCF630F8"
patches:
"0.8.0":
- patch_file: "patches/0001-Make-how-Qt-packages-are-found-more-convinient.patch"
- patch_file: "patches/0002-Fix-debug-build-against-MSVC2022.patch"
74 changes: 40 additions & 34 deletions recipes/qcoro/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
from conan import ConanFile
from conans import tools
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get
from conan.tools.env import VirtualBuildEnv
from conan.tools.scm import Version
import os

required_conan_version = ">=1.33.0"
Expand All @@ -23,17 +28,10 @@ class QCoroConan(ConanFile):
"fPIC": True,
"asan": False,
}
generators = "cmake", "cmake_find_package_multi"
exports_sources = ["CMakeLists.txt"]
_cmake = None

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

@property
def _build_subfolder(self):
return "build_subfolder"
def export_sources(self):
export_conandata_patches(self)

@property
def _compilers_minimum_version(self):
Expand All @@ -55,10 +53,13 @@ def configure(self):
del self.options.fPIC

def build_requirements(self):
self.build_requires("cmake/3.23.2")
self.build_requires("cmake/3.26.4")

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

def requirements(self):
self.requires("qt/6.3.1")
self.requires("qt/6.5.0")

def validate(self):
if self.settings.compiler.cppstd:
Expand All @@ -70,7 +71,7 @@ def lazy_lt_semver(v1, v2):
min_length = min(len(lv1), len(lv2))
return lv1[:min_length] < lv2[:min_length]

#Special check for clang that can only be linked to libc++
# Special check for clang that can only be linked to libc++
if self.settings.compiler == "clang" and self.settings.compiler.libcxx != "libc++":
raise ConanInvalidConfiguration("imagl requires some C++20 features, which are available in libc++ for clang compiler.")

Expand All @@ -85,31 +86,36 @@ def lazy_lt_semver(v1, v2):
print("Your compiler is {} {} and is compatible.".format(str(self.settings.compiler), compiler_version))

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

def _configure_cmake(self):
if self._cmake:
return self._cmake

self._cmake = CMake(self)

self._cmake.definitions["QCORO_BUILD_EXAMPLES"] = False
self._cmake.definitions["QCORO_ENABLE_ASAN"] = self.options.asan
self._cmake.definitions["BUILD_TESTING"] = False
self._cmake.definitions["QCORO_WITH_QTDBUS"] = self.options["qt"].with_dbus
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["USE_QT_VERSION"] = Version(self.deps_cpp_info["qt"].version).major
tc.variables["QCORO_BUILD_EXAMPLES"] = False
tc.variables["QCORO_DISABLE_DEPRECATED_TASK_H"] = True
tc.variables["QCORO_ENABLE_ASAN"] = self.options.asan
tc.variables["BUILD_TESTING"] = False
tc.variables["QCORO_WITH_QTDBUS"] = self.options["qt"].with_dbus
tc.variables["QCORO_WITH_QTQUICK"] = False
tc.variables["QCORO_WITH_QML"] = False
tc.variables["QCORO_WITH_QTWEBSOCKETS"] = False
tc.variables["QCORO_EXCEPTION_MESSAGE_PRINT"] = True
tc.generate()
tc = CMakeDeps(self)
tc.generate()
tc = VirtualBuildEnv(self)
tc.generate(scope="build")

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("*", dst="licenses", src=os.path.join(self._source_subfolder, "LICENSES"))
cmake = self._configure_cmake()
self.copy("*", dst="licenses", src=os.path.join(self.source_folder, "LICENSES"))
cmake = CMake(self)
cmake.install()

for mask in ["Find*.cmake", "*Config*.cmake", "*-config.cmake", "*Targets*.cmake"]:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From 49b27a7dd26044a027a56fdc1247da154da3c01c Mon Sep 17 00:00:00 2001
From: Paul T <developer.paul.123@gmail.com>
Date: Thu, 6 Apr 2023 15:16:41 -0400
Subject: [PATCH] Make how Qt packages are found more convinient

This change allows users to specify `Qt5_DIR` or `Qt6_DIR` and then the rest of the components are automatically found. Prior to this, since `find_package()` was called for each component of Qt, CMake configuring would fail with each component not found. So you would have to specify all the paths at once.
---
cmake/QCoroFindQt.cmake | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/cmake/QCoroFindQt.cmake b/cmake/QCoroFindQt.cmake
index 9bda234..9951b02 100644
--- a/cmake/QCoroFindQt.cmake
+++ b/cmake/QCoroFindQt.cmake
@@ -12,17 +12,11 @@ macro(qcoro_find_qt)
set(ARGS_QT_VERSION 5)
endif()
endif()
+
+ list(APPEND REQUIRED_QT_COMPONENTS "${ARGS_QT${ARGS_QT_VERSION}_COMPONENTS}")
+ list(FILTER REQUIRED_QT_COMPONENTS EXCLUDE REGEX "Private$$")

- foreach (component IN LISTS ARGS_COMPONENTS ARGS_QT${ARGS_QT_VERSION}_COMPONENTS)
- message(STATUS "Qt component: ${component}")
- if ("${component}" MATCHES "Private$$")
- string(REPLACE "Private" "" base_component "${component}")
- find_package(Qt${ARGS_QT_VERSION}${base_component} REQUIRED COMPONENTS Private)
- else()
- find_package(Qt${ARGS_QT_VERSION}${component} REQUIRED)
- endif()
- endforeach()
+ find_package(Qt${ARGS_QT_VERSION} REQUIRED COMPONENTS ${REQUIRED_QT_COMPONENTS})

set(${ARGS_FOUND_VER_VAR} ${ARGS_QT_VERSION})
endmacro()
-
--
2.39.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 1e6c27128c452a631ac486cb8f8d02d4bc1167aa Mon Sep 17 00:00:00 2001
From: Robert Griebl <robert.griebl@qt.io>
Date: Mon, 6 Mar 2023 13:27:24 +0100
Subject: [PATCH] Fix debug build against MSVC2022

Due to the level-4 warnings and warnings-are-errors in debug builds,
we are running into warnings in Qt's private headers and an unused
warning for the "args" pack in invokeCb()
---
qcoro/qcorotask.h | 2 +-
qcoro/qml/qcoroqmltask.cpp | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/qcoro/qcorotask.h b/qcoro/qcorotask.h
index 26f3e7b..1d1e87a 100644
--- a/qcoro/qcorotask.h
+++ b/qcoro/qcorotask.h
@@ -581,7 +581,7 @@ public:

private:
template<typename ThenCallback, typename ... Args>
- auto invokeCb(ThenCallback &&callback, Args && ... args) {
+ auto invokeCb(ThenCallback &&callback, [[maybe_unused]] Args && ... args) {
if constexpr (std::is_invocable_v<ThenCallback, Args ...>) {
return callback(std::forward<Args>(args) ...);
} else {
diff --git a/qcoro/qml/qcoroqmltask.cpp b/qcoro/qml/qcoroqmltask.cpp
index 48136d6..f859cae 100644
--- a/qcoro/qml/qcoroqmltask.cpp
+++ b/qcoro/qml/qcoroqmltask.cpp
@@ -9,7 +9,10 @@
#include <optional>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_MSVC(4458 4201)
#include <private/qjsvalue_p.h>
+QT_WARNING_POP
#endif

Q_DECLARE_LOGGING_CATEGORY(qcoroqml)
--
2.39.2

2 changes: 1 addition & 1 deletion recipes/qcoro/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TestPackageConan(ConanFile):
generators = "cmake", "cmake_find_package"

def build_requirements(self):
self.build_requires("cmake/3.23.2")
self.build_requires("cmake/3.26.4")

def build(self):
cmake = CMake(self)
Expand Down
2 changes: 2 additions & 0 deletions recipes/qcoro/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"0.4.0":
folder: all
"0.8.0":
folder: all