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

qt (5 & 6): provide versionless Qt targets in CMakeDeps #25198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 6 additions & 1 deletion recipes/qt/5.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@

def _debug_output(self, message):
if Version(conan_version) >= "2":
self.output.debug(message)

Check failure on line 213 in recipes/qt/5.x.x/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Instance of 'ScopedOutput' has no 'debug' member. Please, check https://github.com/conan-io/conan-center-index/blob/master/docs/v2_linter.md

def configure(self):
# if self.settings.os != "Linux":
Expand Down Expand Up @@ -862,7 +862,7 @@
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 @@ -976,7 +976,7 @@
filecontents += 'set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_GADGET_EXPORT" "Q_NAMESPACE" "Q_NAMESPACE_EXPORT")\n'
save(self, os.path.join(self.package_folder, self._cmake_core_extras_file), filecontents)

def _create_private_module(module, dependencies=[]):

Check warning on line 979 in recipes/qt/5.x.x/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Dangerous default value [] as argument
if "Core" not in dependencies:
dependencies.append("Core")
dependencies_string = ';'.join(f'Qt5::{dependency}' for dependency in dependencies)
Expand Down Expand Up @@ -1047,10 +1047,11 @@
reqs.append(corrected_req)
return reqs

def _create_module(module, requires=[], has_include_dir=True):

Check warning on line 1050 in recipes/qt/5.x.x/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Dangerous default value [] as argument
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 @@
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 @@
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 @@
_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 @@

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
Loading