Closed Vertexwahn closed 1 year ago
It's good to figure out how to build Qt on Macos as external bazel dependency at all. Installing it manually or through package manager defeats the purpose - you can just copy-paste shared libs + headers to include and link paths and get the same result.
@bedbad
I added prebuild Qt 6.4.0 for macOS (Intel) here: https://vertexwahn.de/lfs/v1/qt_6.4.0_mac_desktop_clang_64.tar.xz
The problem here I do not understand how to reference in this archive all the Qt headers and libraries.
Current try:
qt_6.4.0_mac_desktop_clang_64.BUILD:
load("@rules_qt//:qt_libraries.bzl", "QT_LIBRARIES")
[
cc_library(
name = "qt_%s_mac" % name,
hdrs = glob(["lib/%s.framework/**" % include_folder]),
includes = [
"include",
"include/QtCore",
],
linkopts = ["-Flib"] + [
"-framework %s" % library_name.replace("6", ""), # macOS qt libs do not contain a 6 - e.g. instead of Qt6Core the lib is called QtCore
],
target_compatible_with = ["@platforms//os:osx", "@platforms//cpu:x86_64"],
visibility = ["//visibility:public"],
)
for name, include_folder, library_name, _ in QT_LIBRARIES
]
cc_library(
name = "qt_hdrs",
hdrs = glob(["include/**"]),
includes = [
"include",
],
visibility = ["//visibility:public"],
)
filegroup(
name = "uic",
srcs = ["libexec/uic"],
visibility = ["//visibility:public"],
)
filegroup(
name = "moc",
srcs = ["libexec/moc"],
visibility = ["//visibility:public"],
)
filegroup(
name = "rcc",
srcs = ["libexec/rcc"],
visibility = ["//visibility:public"],
)
filegroup(
name = "plugin_files",
srcs = glob(["plugins/**/*"]),
visibility = ["//visibility:public"],
)
filegroup(
name = "qml_files",
srcs = glob(["qml/**/*"]),
visibility = ["//visibility:public"],
)
This gives the error:
hello_world/hello_world.cpp:1:10: fatal error: 'QtCore/QThread' file not found
#include <QtCore/QThread>
^~~~~~~~~~~~~~~~
I am happy about every support...
Rules work on macOS when Qt is preinstalled. To get rules working with a non-preinstallation on macOS there is a separate issue.
Problem description
Results in:
Expected result
This should also work with macOS Monterey 12.3.1 (x86 Intel) (or newer if available)
build_and_test_macos
should turn green https://github.com/Vertexwahn/rules_qt6/blob/f0221dda34851d6c1284f75343257539ff947d34/.github/workflows/bazel_build.yml#L59Currently, the build status is red since the macOS 11 build does not work. macOS 11 or the newest available version of macOS in GitHub workflow should result in a green build
Hints
The file qt_6.2.4_mac_desktop_clang_64.BUILD needs some modification to find the path of Qt in macOS.
Similar problem described here.