From 2eedf9b3f5a6cbda46087ded9de29d753b711697 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Tue, 10 Sep 2024 02:03:39 +0200 Subject: [PATCH] provide versionless Qt targets in CMakeDeps --- recipes/qt/5.x.x/conanfile.py | 7 ++++++- recipes/qt/6.x.x/conanfile.py | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/recipes/qt/5.x.x/conanfile.py b/recipes/qt/5.x.x/conanfile.py index 0ad50b6ce723c..1d14e7025ae1b 100644 --- a/recipes/qt/5.x.x/conanfile.py +++ b/recipes/qt/5.x.x/conanfile.py @@ -862,7 +862,7 @@ def _getenvpath(var): if self.settings.compiler == "apple-clang" and self.options.qtmultimedia: # XCode 14.3 finally removes std::unary_function, so compilation fails # when using newer SDKs when using C++17 or higher. - # This macro re-enables them. Should be safe to pass this macro even + # This macro re-enables them. Should be safe to pass this macro even # in earlier versions, as it would have no effect. args += ['QMAKE_CXXFLAGS+="-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION=1"'] @@ -1051,6 +1051,7 @@ def _create_module(module, requires=[], has_include_dir=True): componentname = f"qt{module}" assert componentname not in self.cpp_info.components, f"Module {module} already present in self.cpp_info.components" self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt5::{module}") + self.cpp_info.components[componentname].set_property("cmake_target_aliases", [f"Qt::{module}"]) self.cpp_info.components[componentname].set_property("pkg_config_name", f"Qt5{module}") self.cpp_info.components[componentname].names["cmake_find_package"] = module self.cpp_info.components[componentname].names["cmake_find_package_multi"] = module @@ -1077,6 +1078,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): componentname = f"qt{pluginname}" assert componentname not in self.cpp_info.components, f"Plugin {pluginname} already present in self.cpp_info.components" self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt5::{pluginname}") + self.cpp_info.components[componentname].set_property("cmake_target_aliases", [f"Qt::{pluginname}"]) self.cpp_info.components[componentname].names["cmake_find_package"] = pluginname self.cpp_info.components[componentname].names["cmake_find_package_multi"] = pluginname if not self.options.shared: @@ -1110,6 +1112,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): module = "WinMain" componentname = f"qt{module}" self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt5::{module}") + self.cpp_info.components[componentname].set_property("cmake_target_aliases", [f"Qt::{module}"]) self.cpp_info.components[componentname].names["cmake_find_package"] = module self.cpp_info.components[componentname].names["cmake_find_package_multi"] = module self.cpp_info.components[componentname].libs = [f"qtmain{libsuffix}"] @@ -1273,6 +1276,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): _add_build_module("qtQml", self._cmake_qt5_private_file("Qml")) _create_module("QmlModels", ["Qml"]) self.cpp_info.components["qtQmlImportScanner"].set_property("cmake_target_name", "Qt5::QmlImportScanner") + self.cpp_info.components["qtQmlImportScanner"].set_property("cmake_target_aliases", ["Qt::QmlImportScanner"]) self.cpp_info.components["qtQmlImportScanner"].names["cmake_find_package"] = "QmlImportScanner" # this is an alias for Qml and there to integrate with existing consumers self.cpp_info.components["qtQmlImportScanner"].names["cmake_find_package_multi"] = "QmlImportScanner" self.cpp_info.components["qtQmlImportScanner"].requires = _get_corrected_reqs(["Qml"]) @@ -1287,6 +1291,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): if self.options.qttools and self.options.gui and self.options.widgets: self.cpp_info.components["qtLinguistTools"].set_property("cmake_target_name", "Qt5::LinguistTools") + self.cpp_info.components["qtLinguistTools"].set_property("cmake_target_aliases", ["Qt::LinguistTools"]) self.cpp_info.components["qtLinguistTools"].names["cmake_find_package"] = "LinguistTools" self.cpp_info.components["qtLinguistTools"].names["cmake_find_package_multi"] = "LinguistTools" _create_module("UiPlugin", ["Gui", "Widgets"]) diff --git a/recipes/qt/6.x.x/conanfile.py b/recipes/qt/6.x.x/conanfile.py index 508b43c683f44..effc12232fca1 100644 --- a/recipes/qt/6.x.x/conanfile.py +++ b/recipes/qt/6.x.x/conanfile.py @@ -1035,6 +1035,7 @@ def _create_module(module, requires, has_include_dir=True): componentname = f"qt{module}" assert componentname not in self.cpp_info.components, f"Module {module} already present in self.cpp_info.components" self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt6::{module}") + self.cpp_info.components[componentname].set_property("cmake_target_aliases", [f"Qt::{module}"]) self.cpp_info.components[componentname].set_property("pkg_config_name", f"Qt6{module}") self.cpp_info.components[componentname].names["cmake_find_package"] = module self.cpp_info.components[componentname].names["cmake_find_package_multi"] = module @@ -1054,6 +1055,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): componentname = f"qt{pluginname}" assert componentname not in self.cpp_info.components, f"Plugin {pluginname} already present in self.cpp_info.components" self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt6::{pluginname}") + self.cpp_info.components[componentname].set_property("cmake_target_aliases", [f"Qt::{pluginname}"]) self.cpp_info.components[componentname].names["cmake_find_package"] = pluginname self.cpp_info.components[componentname].names["cmake_find_package_multi"] = pluginname if not self.options.shared: @@ -1096,6 +1098,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): self.cpp_info.components["qtCore"].system_libs.append("synchronization") self.cpp_info.components["qtCore"].system_libs.append("runtimeobject") self.cpp_info.components["qtPlatform"].set_property("cmake_target_name", "Qt6::Platform") + self.cpp_info.components["qtPlatform"].set_property("cmake_target_aliases", ["Qt::Platform"]) self.cpp_info.components["qtPlatform"].names["cmake_find_package"] = "Platform" self.cpp_info.components["qtPlatform"].names["cmake_find_package_multi"] = "Platform" self.cpp_info.components["qtPlatform"].includedirs = [os.path.join("mkspecs", self._xplatform())] @@ -1273,6 +1276,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): _add_build_module("qtQml", self._cmake_qt6_private_file("Qml")) _create_module("QmlModels", ["Qml"]) self.cpp_info.components["qtQmlImportScanner"].set_property("cmake_target_name", "Qt6::QmlImportScanner") + self.cpp_info.components["qtQmlImportScanner"].set_property("cmake_target_aliases", ["Qt::QmlImportScanner"]) self.cpp_info.components["qtQmlImportScanner"].names["cmake_find_package"] = "QmlImportScanner" # this is an alias for Qml and there to integrate with existing consumers self.cpp_info.components["qtQmlImportScanner"].names["cmake_find_package_multi"] = "QmlImportScanner" self.cpp_info.components["qtQmlImportScanner"].requires = _get_corrected_reqs(["Qml"]) @@ -1287,6 +1291,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): if self.options.qttools and self.options.gui and self.options.widgets: self.cpp_info.components["qtLinguistTools"].set_property("cmake_target_name", "Qt6::LinguistTools") + self.cpp_info.components["qtLinguistTools"].set_property("cmake_target_aliases", ["Qt::LinguistTools"]) self.cpp_info.components["qtLinguistTools"].names["cmake_find_package"] = "LinguistTools" self.cpp_info.components["qtLinguistTools"].names["cmake_find_package_multi"] = "LinguistTools" _create_module("UiPlugin", ["Gui", "Widgets"]) @@ -1466,6 +1471,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): if self.settings.os in ["Windows", "iOS"]: if self.settings.os == "Windows": self.cpp_info.components["qtEntryPointImplementation"].set_property("cmake_target_name", "Qt6::EntryPointImplementation") + self.cpp_info.components["qtEntryPointImplementation"].set_property("cmake_target_aliases", ["Qt::EntryPointImplementation"]) self.cpp_info.components["qtEntryPointImplementation"].names["cmake_find_package"] = "EntryPointImplementation" self.cpp_info.components["qtEntryPointImplementation"].names["cmake_find_package_multi"] = "EntryPointImplementation" self.cpp_info.components["qtEntryPointImplementation"].libs = [f"Qt6EntryPoint{libsuffix}"] @@ -1473,12 +1479,14 @@ def _create_plugin(pluginname, libname, plugintype, requires): if self.settings.compiler == "gcc": self.cpp_info.components["qtEntryPointMinGW32"].set_property("cmake_target_name", "Qt6::EntryPointMinGW32") + self.cpp_info.components["qtEntryPointMinGW32"].set_property("cmake_target_aliases", ["Qt::EntryPointMinGW32"]) self.cpp_info.components["qtEntryPointMinGW32"].names["cmake_find_package"] = "EntryPointMinGW32" self.cpp_info.components["qtEntryPointMinGW32"].names["cmake_find_package_multi"] = "EntryPointMinGW32" self.cpp_info.components["qtEntryPointMinGW32"].system_libs = ["mingw32"] self.cpp_info.components["qtEntryPointMinGW32"].requires = ["qtEntryPointImplementation"] self.cpp_info.components["qtEntryPointPrivate"].set_property("cmake_target_name", "Qt6::EntryPointPrivate") + self.cpp_info.components["qtEntryPointPrivate"].set_property("cmake_target_aliases", ["Qt::EntryPointPrivate"]) self.cpp_info.components["qtEntryPointPrivate"].names["cmake_find_package"] = "EntryPointPrivate" self.cpp_info.components["qtEntryPointPrivate"].names["cmake_find_package_multi"] = "EntryPointPrivate" if self.settings.os == "Windows":