Skip to content

Commit

Permalink
qt: use upstream package folder architecture
Browse files Browse the repository at this point in the history
fixes #23660
  • Loading branch information
ericLemanissier committed May 10, 2024
1 parent 7c409a6 commit 941ff49
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 84 deletions.
23 changes: 4 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 @@ def build(self):
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 @@ def package(self):
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 Down Expand Up @@ -1049,7 +1035,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("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 +1477,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
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 +1492,7 @@ def _create_plugin(pluginname, libname, plugintype, requires):
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" 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

0 comments on commit 941ff49

Please sign in to comment.