Skip to content

Commit

Permalink
provide versionless Qt targets in CMakeDeps
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceIm committed Sep 10, 2024
1 parent 02291f8 commit 2eedf9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion recipes/qt/5.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"']

Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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}"]
Expand Down Expand Up @@ -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"])
Expand All @@ -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"])
Expand Down
8 changes: 8 additions & 0 deletions recipes/qt/6.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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())]
Expand Down Expand Up @@ -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"])
Expand All @@ -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"])
Expand Down Expand Up @@ -1466,19 +1471,22 @@ 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}"]
self.cpp_info.components["qtEntryPointImplementation"].system_libs = ["shell32"]

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":
Expand Down

0 comments on commit 2eedf9b

Please sign in to comment.