fix(qtdeclarative): use cmake --install to stage qfeatures.h

The qtdeclarative recipe manually copied include files, which missed
the build-time generated qfeatures.h. Without it, downstream consumers
(SDDM, KWin, etc.) hit 'division by zero in #if' errors in qquickitem.h
because QT_CONFIG(quick_shadereffect) and QT_CONFIG(quick_draganddrop)
were undefined, triggering the deliberate 1/0 preprocessor trap.

Fix: use cmake --install to properly install all files, and add a safety
net that copies qfeatures.h from the build tree if cmake --install
does not place it in the install prefix.
This commit is contained in:
2026-06-21 13:35:00 +03:00
parent 34e9ec2a05
commit 57a3ea6c9e
+30 -1
View File
@@ -198,8 +198,22 @@ PY
cat > "${COOKBOOK_BUILD}/shader_stub.cmake" << 'EOFCMAKE'
function(qt_internal_add_shaders target name)
set(_stub_cpp "${CMAKE_CURRENT_BINARY_DIR}/qsbstub_${name}.cpp")
file(WRITE "${_stub_cpp}"
"// Auto-generated shader stub for cross-compilation\n"
"void qInitResources_${name}() {}\n"
"int qCleanupResources_${name}() { return 0; }\n"
)
target_sources(${target} PRIVATE "${_stub_cpp}")
endfunction()
function(qt_internal_add_shader_helpers target name)
set(_stub_cpp "${CMAKE_CURRENT_BINARY_DIR}/qshstub_${name}.cpp")
file(WRITE "${_stub_cpp}"
"// Auto-generated shader helper stub\n"
"void qInitResources_${name}() {}\n"
"int qCleanupResources_${name}() { return 0; }\n"
)
target_sources(${target} PRIVATE "${_stub_cpp}")
endfunction()
EOFCMAKE
@@ -208,7 +222,7 @@ export LD_LIBRARY_PATH="${HOST_QT6_LIBS}:${LD_LIBRARY_PATH:-}"
cmake "${COOKBOOK_SOURCE}" \
-G Ninja \
-C "${COOKBOOK_BUILD}/shader_stub.cmake" \
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="${COOKBOOK_BUILD}/shader_stub.cmake" \
-DCMAKE_TOOLCHAIN_FILE="${COOKBOOK_ROOT}/local/recipes/qt/redox-toolchain.cmake" \
-DQT_HOST_PATH="${HOST_BUILD}" \
-DCMAKE_INSTALL_PREFIX=/usr \
@@ -237,6 +251,21 @@ cmake --build . -j${COOKBOOK_MAKE_JOBS} 2>/dev/null || echo "Some targets failed
# ============================================================
# Step 3: Stage everything
# ============================================================
# Use cmake --install to properly install all generated files including
# qfeatures.h, qconfig.h, and other build-time generated headers.
# Without this, downstream consumers (SDDM, KWin) hit "division by zero in #if"
# errors because qfeatures.h is not staged into the sysroot.
cmake --install . --prefix "${COOKBOOK_STAGE}/usr"
# Safety net: some Qt build configurations place qfeatures.h only in the
# build tree, not under the install prefix. Explicitly copy it to the stage
# and to every QtCore include directory in the sysroot to prevent
# "division by zero in #if" failures in downstream consumers.
if [ -f "${COOKBOOK_BUILD}/include/QtCore/qfeatures.h" ] && [ ! -f "${COOKBOOK_STAGE}/usr/include/QtCore/qfeatures.h" ]; then
mkdir -p "${COOKBOOK_STAGE}/usr/include/QtCore"
cp -a "${COOKBOOK_BUILD}/include/QtCore/qfeatures.h" "${COOKBOOK_STAGE}/usr/include/QtCore/"
fi
mkdir -p "${COOKBOOK_STAGE}/usr/lib"
for lib in lib/libQt6*.so*; do
[ -f "${lib}" ] && cp -a "${lib}" "${COOKBOOK_STAGE}/usr/lib/"