build(grantlee): preserve Qt5 find_package COMPONENTS when mapping to Qt6; improve replacements

This commit is contained in:
Copilot authored and Torsten Wierschin committed 2026-07-20 18:57:29 +02:00
1 parent 3dad1d54ba
commit 92888ddd8d
1 file changed
+14
+14
View File
@@ -29,6 +29,20 @@ git ls-files | grep -E "CMakeLists.txt|\\.cmake$" | xargs -r -n1 -I{} cp {} {}.b
python3 - <<'PY'
import re
from pathlib import Path
# first, convert find_package(Qt5 COMPONENTS ...) preserving components
pat_fp = re.compile(r'find_package\s*\(\s*Qt5\s+COMPONENTS\s+([^\)]+)\)', re.M)
for p in Path('.').rglob('*'):
if p.is_file() and (p.name=='CMakeLists.txt' or p.suffix=='.cmake'):
try:
s = p.read_text()
s2 = pat_fp.sub(lambda m: 'find_package(Qt6 REQUIRED COMPONENTS %s)'%m.group(1).strip(), s)
if s2 != s:
p.write_text(s2)
print('Patched find_package components in', p)
except Exception as e:
print('Skipping', p, 'error', e)
# generic replacements
patterns = [
(re.compile(r'find_package\s*\(\s*Qt5[^)]*\)', re.M), 'find_package(Qt6 REQUIRED COMPONENTS Core Widgets)'),
(re.compile(r'Qt5::'), 'Qt6::'),