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: use upstream package folder architecture #23944

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
24 changes: 5 additions & 19 deletions recipes/qt/5.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,6 @@
if cross_building(self):
args.append(f"-extprefix {self.package_folder}")
args.append("-v")
args.append("-archdatadir %s" % os.path.join(self.package_folder, "bin", "archdatadir"))
args.append("-datadir %s" % os.path.join(self.package_folder, "bin", "datadir"))
args.append("-sysconfdir %s" % os.path.join(self.package_folder, "bin", "sysconfdir"))
if self.options.commercial:
args.append("-commercial")
else:
Expand Down Expand Up @@ -854,18 +851,7 @@
with chdir(self, "build_folder"):
self.run(f"{self._make_program()} install")
save(self, os.path.join(self.package_folder, "bin", "qt.conf"), """[Paths]
Prefix = ..
ArchData = bin/archdatadir
HostData = bin/archdatadir
Data = bin/datadir
Sysconf = bin/sysconfdir
LibraryExecutables = bin/archdatadir/bin
Plugins = bin/archdatadir/plugins
Imports = bin/archdatadir/imports
Qml2Imports = bin/archdatadir/qml
Translations = bin/datadir/translations
Documentation = bin/datadir/doc
Examples = bin/datadir/examples""")
Prefix = ..""")
copy(self, "*LICENSE*", os.path.join(self.source_folder, "qt5/"), os.path.join(self.package_folder, "licenses"),
excludes="qtbase/examples/*")
for module in self._submodules:
Expand All @@ -877,6 +863,7 @@
rm(self, "*.la*", os.path.join(self.package_folder, "lib"), recursive=True)
rm(self, "*.pdb*", os.path.join(self.package_folder, "lib"), recursive=True)
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"), recursive=True)
rm(self, "*.pdb", os.path.join(self.package_folder, "plugins"), recursive=True)
# "Qt5Bootstrap" is internal Qt library - removing it to avoid linking error, since it contains
# symbols that are also in "Qt5Core.lib". It looks like there is no "Qt5Bootstrap.dll".
for fl in glob.glob(os.path.join(self.package_folder, "lib", "*Qt5Bootstrap*")):
Expand Down Expand Up @@ -946,7 +933,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 936 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 @@ -1015,7 +1002,7 @@
reqs.append(corrected_req)
return reqs

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

Check warning on line 1005 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}")
Expand Down Expand Up @@ -1049,7 +1036,7 @@
self.cpp_info.components[componentname].names["cmake_find_package_multi"] = pluginname
if not self.options.shared:
self.cpp_info.components[componentname].libs = [libname + libsuffix]
self.cpp_info.components[componentname].libdirs = [os.path.join("bin", "archdatadir", "plugins", plugintype)]
self.cpp_info.components[componentname].libdirs = [os.path.join("plugins", plugintype)]
self.cpp_info.components[componentname].includedirs = []
if "Core" not in requires:
requires.append("Core")
Expand Down Expand Up @@ -1491,7 +1478,7 @@
self.cpp_info.components["qtCore"].frameworks.append("Cocoa") # qtcore requires "_OBJC_CLASS_$_NSApplication" and more, which are in "Cocoa" framework
self.cpp_info.components["qtCore"].frameworks.append("Security") # qtcore requires "_SecRequirementCreateWithString" and more, which are in "Security" framework

self.cpp_info.components["qtCore"].builddirs.append(os.path.join("bin","archdatadir","bin"))
self.cpp_info.components["qtCore"].builddirs.append(os.path.join("bin"))
_add_build_module("qtCore", self._cmake_core_extras_file)
_add_build_module("qtCore", self._cmake_qt5_private_file("Core"))

Expand All @@ -1506,8 +1493,7 @@
os.path.join("lib", "cmake", "Qt5Core", "Qt5CoreConfigExtrasMkspecDir.cmake"))
mkspecs_dir_begin = qt5core_config_extras_mkspec_dir_cmake.find("mkspecs/")
mkspecs_dir_end = qt5core_config_extras_mkspec_dir_cmake.find("\"", mkspecs_dir_begin)
mkspecs_dir = qt5core_config_extras_mkspec_dir_cmake[mkspecs_dir_begin:mkspecs_dir_end].split('/')
mkspecs_path = os.path.join("bin", "archdatadir", *mkspecs_dir)
mkspecs_path = qt5core_config_extras_mkspec_dir_cmake[mkspecs_dir_begin:mkspecs_dir_end]
assert os.path.exists(mkspecs_path)
self.cpp_info.components["qtCore"].includedirs.append(mkspecs_path)

Expand Down
11 changes: 0 additions & 11 deletions recipes/qt/5.x.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ def generate(self):
qt_conf = textwrap.dedent(f"""\
[Paths]
Prefix = {qt_install_prefix}
ArchData = bin/archdatadir
HostData = bin/archdatadir
Data = bin/datadir
Sysconf = bin/sysconfdir
LibraryExecutables = bin/archdatadir/bin
Plugins = bin/archdatadir/plugins
Imports = bin/archdatadir/imports
Qml2Imports = bin/archdatadir/qml
Translations = bin/datadir/translations
Documentation = bin/datadir/doc
Examples = bin/datadir/examples
""")
save(self, "qt.conf", qt_conf)

Expand Down
13 changes: 1 addition & 12 deletions recipes/qt/5.x.x/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,7 @@ def build_requirements(self):

def generate(self):
save(self, "qt.conf", """[Paths]
Prefix = {}
ArchData = bin/archdatadir
HostData = bin/archdatadir
Data = bin/datadir
Sysconf = bin/sysconfdir
LibraryExecutables = bin/archdatadir/bin
Plugins = bin/archdatadir/plugins
Imports = bin/archdatadir/imports
Qml2Imports = bin/archdatadir/qml
Translations = bin/datadir/translations
Documentation = bin/datadir/doc
Examples = bin/datadir/examples""".format(self.dependencies["qt"].package_folder.replace('\\', '/')))
Prefix = {}""".format(self.dependencies["qt"].package_folder.replace('\\', '/')))

def _is_mingw(self):
return self.settings.os == "Windows" and self.settings.compiler == "gcc"
Expand Down
26 changes: 11 additions & 15 deletions recipes/qt/6.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,6 @@ def generate(self):

tc = CMakeToolchain(self, generator="Ninja")

package_folder = self.package_folder.replace('\\', '/')
tc.variables["INSTALL_MKSPECSDIR"] = f"{package_folder}/res/archdatadir/mkspecs"
tc.variables["INSTALL_ARCHDATADIR"] = f"{package_folder}/res/archdatadir"
tc.variables["INSTALL_LIBEXECDIR"] = f"{package_folder}/bin"
tc.variables["INSTALL_DATADIR"] = f"{package_folder}/res/datadir"
tc.variables["INSTALL_SYSCONFDIR"] = f"{package_folder}/res/sysconfdir"

tc.variables["QT_BUILD_TESTS"] = "OFF"
tc.variables["QT_BUILD_EXAMPLES"] = "OFF"

Expand Down Expand Up @@ -818,7 +811,7 @@ def package(self):
rm(self, "*.la*", os.path.join(self.package_folder, "lib"), recursive=True)
rm(self, "*.pdb*", self.package_folder, recursive=True)
rm(self, "ensure_pro_file.cmake", self.package_folder, recursive=True)
os.remove(os.path.join(self.package_folder, "bin", "qt-cmake-private-install.cmake"))
os.remove(os.path.join(self.package_folder, "libexec" if Version(self.version) >= "6.5.0" and self.settings.os != "Windows" else "bin", "qt-cmake-private-install.cmake"))

for m in os.listdir(os.path.join(self.package_folder, "lib", "cmake")):
if os.path.isfile(os.path.join(self.package_folder, "lib", "cmake", m, f"{m}Macros.cmake")):
Expand Down Expand Up @@ -865,10 +858,13 @@ def package(self):
for target in targets:
exe_path = None
for path_ in [f"bin/{target}{extension}",
f"lib/{target}{extension}"]:
f"lib/{target}{extension}",
f"libexec/{target}{extension}"]:
if os.path.isfile(os.path.join(self.package_folder, path_)):
exe_path = path_
break
else:
assert False, f"Could not find executable {target}{extension} in {self.package_folder}"
if not exe_path:
self.output.warning(f"Could not find path to {target}{extension}")
filecontents += textwrap.dedent(f"""\
Expand Down Expand Up @@ -943,8 +939,8 @@ def package_info(self):
self.cpp_info.names["cmake_find_package_multi"] = "Qt6"

# consumers will need the QT_PLUGIN_PATH defined in runenv
self.runenv_info.define("QT_PLUGIN_PATH", os.path.join(self.package_folder, "res", "archdatadir", "plugins"))
self.buildenv_info.define("QT_PLUGIN_PATH", os.path.join(self.package_folder, "res", "archdatadir", "plugins"))
self.runenv_info.define("QT_PLUGIN_PATH", os.path.join(self.package_folder, "plugins"))
self.buildenv_info.define("QT_PLUGIN_PATH", os.path.join(self.package_folder, "plugins"))

self.buildenv_info.define("QT_HOST_PATH", self.package_folder)

Expand Down Expand Up @@ -1001,7 +997,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
self.cpp_info.components[componentname].names["cmake_find_package_multi"] = pluginname
if not self.options.shared:
self.cpp_info.components[componentname].libs = [libname + libsuffix]
self.cpp_info.components[componentname].libdirs = [os.path.join("res", "archdatadir", "plugins", plugintype)]
self.cpp_info.components[componentname].libdirs = [os.path.join("plugins", plugintype)]
self.cpp_info.components[componentname].includedirs = []
if "Core" not in requires:
requires.append("Core")
Expand All @@ -1024,7 +1020,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
_create_module("Core", core_reqs)
pkg_config_vars = [
"bindir=${prefix}/bin",
"libexecdir=${prefix}/bin",
"libexecdir=${prefix}/libexec",
"exec_prefix=${prefix}",
]
self.cpp_info.components["qtCore"].set_property("pkg_config_custom_content", "\n".join(pkg_config_vars))
Expand All @@ -1041,7 +1037,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
self.cpp_info.components["qtPlatform"].set_property("cmake_target_name", "Qt6::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("res", "archdatadir", "mkspecs", self._xplatform())]
self.cpp_info.components["qtPlatform"].includedirs = [os.path.join("mkspecs", self._xplatform())]
if self.options.with_dbus:
_create_module("DBus", ["dbus::dbus"])
if self.settings.os == "Windows":
Expand Down Expand Up @@ -1501,7 +1497,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
# https://github.com/qt/qtbase/blob/v6.6.1/src/corelib/CMakeLists.txt#L1079-L1082
self.cpp_info.components["qtCore"].frameworks.append("WatchKit")

self.cpp_info.components["qtCore"].builddirs.append(os.path.join("res", "archdatadir", "bin"))
self.cpp_info.components["qtCore"].builddirs.append(os.path.join("bin"))
_add_build_module("qtCore", self._cmake_executables_file)
_add_build_module("qtCore", self._cmake_qt6_private_file("Core"))
if self.settings.os in ["Windows", "iOS"]:
Expand Down
16 changes: 1 addition & 15 deletions recipes/qt/6.x.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,8 @@ def build_requirements(self):

def generate(self):
path = self.dependencies["qt"].package_folder.replace("\\", "/")
folder = os.path.join(path, "bin")
bin_folder = "bin" if self.settings.os == "Windows" else "libexec"
save(self, "qt.conf", f"""[Paths]
Prefix = {path}
ArchData = {folder}/archdatadir
HostData = {folder}/archdatadir
Data = {folder}/datadir
Sysconf = {folder}/sysconfdir
LibraryExecutables = {folder}/archdatadir/{bin_folder}
HostLibraryExecutables = bin
Plugins = {folder}/archdatadir/plugins
Imports = {folder}/archdatadir/imports
Qml2Imports = {folder}/archdatadir/qml
Translations = {folder}/datadir/translations
Documentation = {folder}/datadir/doc
Examples = {folder}/datadir/examples""")
Prefix = {path}""")

VirtualRunEnv(self).generate()
if can_run(self):
Expand Down
13 changes: 1 addition & 12 deletions recipes/qt/6.x.x/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,7 @@ def build_requirements(self):

def generate(self):
save(self, "qt.conf", """[Paths]
Prefix = {}
ArchData = bin/archdatadir
HostData = bin/archdatadir
Data = bin/datadir
Sysconf = bin/sysconfdir
LibraryExecutables = bin/archdatadir/bin
Plugins = bin/archdatadir/plugins
Imports = bin/archdatadir/imports
Qml2Imports = bin/archdatadir/qml
Translations = bin/datadir/translations
Documentation = bin/datadir/doc
Examples = bin/datadir/examples""".format(self.dependencies["qt"].package_folder.replace('\\', '/')))
Prefix = {}""".format(self.dependencies["qt"].package_folder.replace('\\', '/')))

def _is_mingw(self):
return self.settings.os == "Windows" and self.settings.compiler == "gcc"
Expand Down
Loading