qml: pin OUTPUT_DIRECTORY of PhpQml.Bridge to match its URI path
Some checks failed
CI / Quality (push) Failing after 3m40s
Release / Linux AppImage (push) Failing after 5m26s

qmllint resolves QML modules by walking the import path looking for a
directory layout that mirrors the URI (PhpQml.Bridge → PhpQml/Bridge/).
qt_add_qml_module's OUTPUT_DIRECTORY defaults to CMAKE_CURRENT_BINARY_DIR
— which, when consumers add_subdirectory() this with their own binary_dir
(skeleton: build/qml/php_qml_bridge, todo: build/qml/php_qml_bridge),
ends in `php_qml_bridge` instead of `PhpQml/Bridge`. cmake configure
warns about the mismatch:

    The php_qml_bridge target is a QML module with target path
    PhpQml/Bridge. It uses an OUTPUT_DIRECTORY of .../php_qml_bridge,
    which should end in the same target path, but doesn't. Tooling
    such as qmllint may not work correctly.

…and at lint time, qmllint can't find the module, so every file that
`import PhpQml.Bridge` (AppShell.qml, DevConsole.qml) fails with
"Failed to import PhpQml.Bridge", which cascades into bogus
"Unqualified access" warnings for every BackendConnection reference.
The cascade exits 255 in Qt 6.5.3's qmllint (CI), even when an older
local qmllint would only warn.

Fix: pin OUTPUT_DIRECTORY in the framework's own qt_add_qml_module so
the layout is correct regardless of how consumers wire up the
add_subdirectory binary_dir. Single source of truth in the framework,
no consumer-side change needed.

Verified locally: rebuild from scratch + `make quality` green
(qmllint clean of the cascade — only the pre-existing
DevConsole/Main.qml warnings remain, all non-fatal). PHPStan +
cs-fixer + 16 tests + maker snapshots also still green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-03 10:48:47 +02:00
parent 64be713b97
commit 1389b92906

View File

@@ -24,6 +24,8 @@ qt_add_qml_module(php_qml_bridge
URI PhpQml.Bridge
VERSION 1.0
STATIC
# OUTPUT_DIRECTORY must mirror the URI for qmllint to resolve the module.
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/PhpQml/Bridge
SOURCES
src/BackendConnection.h
src/BackendConnection.cpp