Skip to content

Commit 2140b0d

Browse files
SpaceImjcar87
andauthored
qt (5 & 6): provide versionless Qt targets in CMakeDeps (#25198)
* provide versionless Qt targets in CMakeDeps * avoid duplication --------- Co-authored-by: Luis Caro Campos <[email protected]>
1 parent 8882738 commit 2140b0d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

recipes/qt/5.x.x/conanfile.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def _getenvpath(var):
866866
if self.settings.compiler == "apple-clang" and self.options.qtmultimedia:
867867
# XCode 14.3 finally removes std::unary_function, so compilation fails
868868
# when using newer SDKs when using C++17 or higher.
869-
# This macro re-enables them. Should be safe to pass this macro even
869+
# This macro re-enables them. Should be safe to pass this macro even
870870
# in earlier versions, as it would have no effect.
871871
args += ['QMAKE_CXXFLAGS+="-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION=1"']
872872

@@ -1058,6 +1058,7 @@ def _create_module(module, requires=[], has_include_dir=True):
10581058
componentname = f"qt{module}"
10591059
assert componentname not in self.cpp_info.components, f"Module {module} already present in self.cpp_info.components"
10601060
self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt5::{module}")
1061+
self.cpp_info.components[componentname].set_property("cmake_target_aliases", [f"Qt::{module}"])
10611062
self.cpp_info.components[componentname].set_property("pkg_config_name", f"Qt5{module}")
10621063
self.cpp_info.components[componentname].names["cmake_find_package"] = module
10631064
self.cpp_info.components[componentname].names["cmake_find_package_multi"] = module
@@ -1084,6 +1085,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
10841085
componentname = f"qt{pluginname}"
10851086
assert componentname not in self.cpp_info.components, f"Plugin {pluginname} already present in self.cpp_info.components"
10861087
self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt5::{pluginname}")
1088+
self.cpp_info.components[componentname].set_property("cmake_target_aliases", [f"Qt::{pluginname}"])
10871089
self.cpp_info.components[componentname].names["cmake_find_package"] = pluginname
10881090
self.cpp_info.components[componentname].names["cmake_find_package_multi"] = pluginname
10891091
if not self.options.shared:
@@ -1120,6 +1122,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
11201122
module = "WinMain"
11211123
componentname = f"qt{module}"
11221124
self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt5::{module}")
1125+
self.cpp_info.components[componentname].set_property("cmake_target_aliases", [f"Qt::{module}"])
11231126
self.cpp_info.components[componentname].names["cmake_find_package"] = module
11241127
self.cpp_info.components[componentname].names["cmake_find_package_multi"] = module
11251128
self.cpp_info.components[componentname].libs = [f"qtmain{libsuffix}"]
@@ -1285,6 +1288,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
12851288
_add_build_module("qtQml", self._cmake_qt5_private_file("Qml"))
12861289
_create_module("QmlModels", ["Qml"])
12871290
self.cpp_info.components["qtQmlImportScanner"].set_property("cmake_target_name", "Qt5::QmlImportScanner")
1291+
self.cpp_info.components["qtQmlImportScanner"].set_property("cmake_target_aliases", ["Qt::QmlImportScanner"])
12881292
self.cpp_info.components["qtQmlImportScanner"].names["cmake_find_package"] = "QmlImportScanner" # this is an alias for Qml and there to integrate with existing consumers
12891293
self.cpp_info.components["qtQmlImportScanner"].names["cmake_find_package_multi"] = "QmlImportScanner"
12901294
self.cpp_info.components["qtQmlImportScanner"].requires = _get_corrected_reqs(["Qml"])
@@ -1299,6 +1303,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
12991303

13001304
if self.options.qttools and self.options.gui and self.options.widgets:
13011305
self.cpp_info.components["qtLinguistTools"].set_property("cmake_target_name", "Qt5::LinguistTools")
1306+
self.cpp_info.components["qtLinguistTools"].set_property("cmake_target_aliases", ["Qt::LinguistTools"])
13021307
self.cpp_info.components["qtLinguistTools"].names["cmake_find_package"] = "LinguistTools"
13031308
self.cpp_info.components["qtLinguistTools"].names["cmake_find_package_multi"] = "LinguistTools"
13041309
_create_module("UiPlugin", ["Gui", "Widgets"])

recipes/qt/6.x.x/conanfile.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ def _create_module(module, requires, has_include_dir=True):
10521052
componentname = f"qt{module}"
10531053
assert componentname not in self.cpp_info.components, f"Module {module} already present in self.cpp_info.components"
10541054
self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt6::{module}")
1055+
self.cpp_info.components[componentname].set_property("cmake_target_aliases", [f"Qt::{module}"])
10551056
self.cpp_info.components[componentname].set_property("pkg_config_name", f"Qt6{module}")
10561057
if module.endswith("Private"):
10571058
libname = module[:-7]
@@ -1069,6 +1070,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
10691070
componentname = f"qt{pluginname}"
10701071
assert componentname not in self.cpp_info.components, f"Plugin {pluginname} already present in self.cpp_info.components"
10711072
self.cpp_info.components[componentname].set_property("cmake_target_name", f"Qt6::{pluginname}")
1073+
self.cpp_info.components[componentname].set_property("cmake_target_aliases", [f"Qt::{pluginname}"])
10721074
if not self.options.shared:
10731075
self.cpp_info.components[componentname].libs = [libname + libsuffix]
10741076
self.cpp_info.components[componentname].libdirs = [os.path.join("plugins", plugintype)]
@@ -1079,6 +1081,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
10791081

10801082
# https://github.com/qt/qtbase/blob/v6.7.3/cmake/QtPlatformTargetHelpers.cmake
10811083
self.cpp_info.components["qtPlatform"].set_property("cmake_target_name", "Qt6::Platform")
1084+
self.cpp_info.components["qtPlatform"].set_property("cmake_target_aliases", ["Qt::Platform"])
10821085
self.cpp_info.components["qtPlatform"].includedirs = [os.path.join("mkspecs", self._xplatform())]
10831086
if self.settings.os == "Android":
10841087
self.cpp_info.components["qtPlatform"].system_libs.append("log")
@@ -1292,6 +1295,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
12921295
_add_build_module("qtQml", self._cmake_qt6_private_file("Qml"))
12931296
_create_module("QmlModels", ["Qml"])
12941297
self.cpp_info.components["qtQmlImportScanner"].set_property("cmake_target_name", "Qt6::QmlImportScanner")
1298+
self.cpp_info.components["qtQmlImportScanner"].set_property("cmake_target_aliases", ["Qt::QmlImportScanner"])
12951299
self.cpp_info.components["qtQmlImportScanner"].requires = _get_corrected_reqs(["Qml"])
12961300
if qt_quick_enabled:
12971301
_create_module("Quick", ["Gui", "Qml", "QmlModels"])
@@ -1304,6 +1308,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
13041308

13051309
if self.options.qttools and self.options.gui and self.options.widgets:
13061310
self.cpp_info.components["qtLinguistTools"].set_property("cmake_target_name", "Qt6::LinguistTools")
1311+
self.cpp_info.components["qtLinguistTools"].set_property("cmake_target_aliases", ["Qt::LinguistTools"])
13071312
_create_module("UiPlugin", ["Gui", "Widgets"])
13081313
self.cpp_info.components["qtUiPlugin"].libs = [] # this is a collection of abstract classes, so this is header-only
13091314
self.cpp_info.components["qtUiPlugin"].libdirs = []
@@ -1481,15 +1486,18 @@ def _create_plugin(pluginname, libname, plugintype, requires):
14811486
if self.settings.os in ["Windows", "iOS"]:
14821487
if self.settings.os == "Windows":
14831488
self.cpp_info.components["qtEntryPointImplementation"].set_property("cmake_target_name", "Qt6::EntryPointImplementation")
1489+
self.cpp_info.components["qtEntryPointImplementation"].set_property("cmake_target_aliases", ["Qt::EntryPointImplementation"])
14841490
self.cpp_info.components["qtEntryPointImplementation"].libs = [f"Qt6EntryPoint{libsuffix}"]
14851491
self.cpp_info.components["qtEntryPointImplementation"].system_libs = ["shell32"]
14861492

14871493
if self.settings.compiler == "gcc":
14881494
self.cpp_info.components["qtEntryPointMinGW32"].set_property("cmake_target_name", "Qt6::EntryPointMinGW32")
1495+
self.cpp_info.components["qtEntryPointMinGW32"].set_property("cmake_target_aliases", ["Qt::EntryPointMinGW32"])
14891496
self.cpp_info.components["qtEntryPointMinGW32"].system_libs = ["mingw32"]
14901497
self.cpp_info.components["qtEntryPointMinGW32"].requires = ["qtEntryPointImplementation"]
14911498

14921499
self.cpp_info.components["qtEntryPointPrivate"].set_property("cmake_target_name", "Qt6::EntryPointPrivate")
1500+
self.cpp_info.components["qtEntryPointPrivate"].set_property("cmake_target_aliases", ["Qt::EntryPointPrivate"])
14931501
if self.settings.os == "Windows":
14941502
if self.settings.compiler == "gcc":
14951503
self.cpp_info.components["qtEntryPointPrivate"].defines.append("QT_NEEDS_QMAIN")

0 commit comments

Comments
 (0)