Files
qt6-migration-pipeline/app/patches/fix_installed_grantlee_config.sh
T

35 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
GRANTLEE_INSTALL_DIR="${1:-./external/grantlee}"
CONFIG_FILE="$GRANTLEE_INSTALL_DIR/lib/cmake/Grantlee5/Grantlee5Config.cmake"
if [ ! -f "$CONFIG_FILE" ]; then
echo "Grantlee config not found at $CONFIG_FILE" >&2
exit 2
fi
# Replace Qt5 -> Qt6 in the installed Grantlee config to match Qt6 migration.
# Be conservative: only replace find_package(Qt5 with find_package(Qt6
# and occurrences of find_package(Qt5 REQUIRED X) -> find_package(Qt6 REQUIRED COMPONENTS X)
cp "$CONFIG_FILE" "$CONFIG_FILE.bak"
# handle common patterns
sed -E -e 's/find_package\(Qt5Required Gui\)/find_package(Qt6 REQUIRED Gui)/g' \
-e 's/find_package\(Qt5 REQUIRED Gui\)/find_package(Qt6 REQUIRED COMPONENTS Gui)/g' \
-e 's/find_package\(Qt5 REQUIRED Core\)/find_package(Qt6 REQUIRED COMPONENTS Core)/g' \
-e 's/find_package\(Qt5 REQUIRED Qml\)/find_package(Qt6 REQUIRED COMPONENTS Qml)/g' \
-e 's/find_package\(Qt5 REQUIRED Qml\)/find_package(Qt6 REQUIRED COMPONENTS Qml)/g' \
-e 's/find_package\(Qt5 REQUIRED /find_package(Qt6 REQUIRED COMPONENTS /g' \
-e 's/find_package\(Qt5Gui REQUIRED\)/find_package(Qt6 REQUIRED COMPONENTS Gui)/g' \
"$CONFIG_FILE.bak" > "$CONFIG_FILE"
# quick sanity check
if grep -q "find_package(Qt5" "$CONFIG_FILE"; then
echo "Warning: Some Qt5 references remain in $CONFIG_FILE" >&2
exit 3
fi
echo "Patched $CONFIG_FILE to use Qt6 (backup at $CONFIG_FILE.bak)"