From 97ef690b8389642013d69769ac539d857b8ff29b Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 9 Nov 2023 15:54:25 +0200 Subject: [PATCH] qcoro: fix build --- recipes/qcoro/all/conanfile.py | 61 ++++++++++--------- recipes/qcoro/all/test_package/conanfile.py | 3 + .../qcoro/all/test_v1_package/conanfile.py | 2 +- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/recipes/qcoro/all/conanfile.py b/recipes/qcoro/all/conanfile.py index acc99781c5b072..8dacd51316b7ce 100644 --- a/recipes/qcoro/all/conanfile.py +++ b/recipes/qcoro/all/conanfile.py @@ -4,10 +4,11 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv from conan.tools.files import apply_conandata_patches, copy, get, rm from conan.tools.scm import Version -required_conan_version = ">=1.53.0" +required_conan_version = ">=1.56.0 <2 || >=2.0.6" class QCoroConan(ConanFile): @@ -36,7 +37,7 @@ def _compilers_minimum_version(self): return { "gcc": "10", "Visual Studio": "17", - "msvc": "19.29", + "msvc": "192", "clang": "8", "apple-clang": "13", } @@ -53,7 +54,7 @@ def layout(self): cmake_layout(self, src_folder="src") def requirements(self): - self.requires("qt/6.6.0") + self.requires("qt/6.6.0", transitive_headers=True, transitive_libs=True) def validate(self): if self.settings.compiler.cppstd: @@ -62,29 +63,30 @@ def validate(self): # 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." + "qcoro requires some C++20 features, which are available in libc++ for clang compiler." ) compiler_version = str(self.settings.compiler.version) - minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if not minimum_version: - self.output.warning("qcoro requires C++20. Your compiler is unknown. Assuming it supports C++20.") - elif Version(compiler_version) < minimum_version: + if minimum_version and Version(compiler_version) < minimum_version: raise ConanInvalidConfiguration( f"qcoro requires some C++20 features, which your {str(self.settings.compiler)} " f"{compiler_version} compiler does not support." ) - else: - print(f"Your compiler is {str(self.settings.compiler)} {compiler_version} and is compatible.") def build_requirements(self): - self.tool_requires("cmake/[>=3.23]") + self.tool_requires("cmake/[>=3.23 <4]") + self.tool_requires("qt/") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): + venv = VirtualBuildEnv(self) + venv.generate() + # Required for Qt's moc + venv = VirtualRunEnv(self) + venv.generate(scope="build") tc = CMakeToolchain(self) tc.variables["QCORO_BUILD_EXAMPLES"] = False tc.variables["QCORO_ENABLE_ASAN"] = self.options.asan @@ -106,40 +108,41 @@ def package(self): src=os.path.join(self.source_folder, "LICENSES")) cmake = CMake(self) cmake.install() - for mask in ["Find*.cmake", "*Config*.cmake", "*-config.cmake", "*Targets*.cmake"]: rm(self, mask, self.package_folder, recursive=True) def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "QCoro6" - self.cpp_info.filenames["cmake_find_package_multi"] = "QCoro6" self.cpp_info.set_property("cmake_file_name", "QCoro6") - self.cpp_info.names["cmake_find_package"] = "QCoro" - self.cpp_info.names["cmake_find_package_multi"] = "QCoro" + + self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "QCoro6Coro")) + macros_cmake_path = os.path.join("lib", "cmake", "QCoro6Coro", "QCoroMacros.cmake") + self.cpp_info.set_property("cmake_build_modules", [macros_cmake_path]) self.cpp_info.components["qcoro-core"].set_property("cmake_target_name", "QCoro::Core") - self.cpp_info.components["qcoro-core"].names["cmake_find_package"] = "Core" - self.cpp_info.components["qcoro-core"].names["cmake_find_package_multi"] = "Core" self.cpp_info.components["qcoro-core"].libs = ["QCoro6Core"] self.cpp_info.components["qcoro-core"].includedirs.append(os.path.join("include", "qcoro6", "qcoro")) self.cpp_info.components["qcoro-core"].requires = ["qt::qtCore"] - self.cpp_info.components["qcoro-core"].build_modules["cmake_find_package"].append( - os.path.join("lib", "cmake", "QCoro6Coro", "QCoroMacros.cmake") - ) - self.cpp_info.components["qcoro-core"].build_modules["cmake_find_package_multi"].append( - os.path.join("lib", "cmake", "QCoro6Coro", "QCoroMacros.cmake") - ) - self.cpp_info.components["qcoro-core"].builddirs.append(os.path.join("lib", "cmake", "QCoro6Coro")) self.cpp_info.components["qcoro-network"].set_property("cmake_target_name", "QCoro::Network") - self.cpp_info.components["qcoro-network"].names["cmake_find_package"] = "Network" - self.cpp_info.components["qcoro-network"].names["cmake_find_package_multi"] = "Network" self.cpp_info.components["qcoro-network"].libs = ["QCoro6Network"] self.cpp_info.components["qcoro-network"].requires = ["qt::qtNetwork"] if self.dependencies["qt"].options.with_dbus: self.cpp_info.components["qcoro-dbus"].set_property("cmake_target_name", "QCoro::DBus") - self.cpp_info.components["qcoro-dbus"].names["cmake_find_package"] = "DBus" - self.cpp_info.components["qcoro-dbus"].names["cmake_find_package_multi"] = "DBus" self.cpp_info.components["qcoro-dbus"].libs = ["QCoroDBus"] self.cpp_info.components["qcoro-core"].requires = ["qt::qtDBus"] + + # TODO: Legacy, to be removed on Conan 2.0 + self.cpp_info.filenames["cmake_find_package"] = "QCoro6" + self.cpp_info.filenames["cmake_find_package_multi"] = "QCoro6" + self.cpp_info.names["cmake_find_package"] = "QCoro" + self.cpp_info.names["cmake_find_package_multi"] = "QCoro" + self.cpp_info.components["qcoro-core"].names["cmake_find_package"] = "Core" + self.cpp_info.components["qcoro-core"].names["cmake_find_package_multi"] = "Core" + self.cpp_info.components["qcoro-network"].names["cmake_find_package"] = "Network" + self.cpp_info.components["qcoro-network"].names["cmake_find_package_multi"] = "Network" + if self.dependencies["qt"].options.with_dbus: + self.cpp_info.components["qcoro-dbus"].names["cmake_find_package"] = "DBus" + self.cpp_info.components["qcoro-dbus"].names["cmake_find_package_multi"] = "DBus" + self.cpp_info.components["qcoro-core"].build_modules["cmake_find_package"].append(macros_cmake_path) + self.cpp_info.components["qcoro-core"].build_modules["cmake_find_package_multi"].append(macros_cmake_path) diff --git a/recipes/qcoro/all/test_package/conanfile.py b/recipes/qcoro/all/test_package/conanfile.py index ef5d7042163ecc..002cdd8cd597f1 100644 --- a/recipes/qcoro/all/test_package/conanfile.py +++ b/recipes/qcoro/all/test_package/conanfile.py @@ -15,6 +15,9 @@ def requirements(self): def layout(self): cmake_layout(self) + def build_requirements(self): + self.tool_requires("cmake/[>=3.23 <4]") + def build(self): cmake = CMake(self) cmake.configure() diff --git a/recipes/qcoro/all/test_v1_package/conanfile.py b/recipes/qcoro/all/test_v1_package/conanfile.py index e665b1b05d751b..2ae403969d8273 100644 --- a/recipes/qcoro/all/test_v1_package/conanfile.py +++ b/recipes/qcoro/all/test_v1_package/conanfile.py @@ -9,7 +9,7 @@ class TestPackageConan(ConanFile): generators = "cmake", "cmake_find_package_multi" def build_requirements(self): - self.build_requires("cmake/3.23.2") + self.build_requires("cmake/[>=3.23 <4]") def build(self): cmake = CMake(self)