From faa891b5736580a9e11ac811156234aa8332ae13 Mon Sep 17 00:00:00 2001 From: Copilot Date: Tue, 21 Jul 2026 12:59:39 +0200 Subject: [PATCH] build(grantlee): strip explicit QT_TESTCASE_BUILDDIR target_compile_definitions to avoid macro redefinition; keep Qt6 Test find_package injection --- app/build_grantlee_qt6.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/build_grantlee_qt6.sh b/app/build_grantlee_qt6.sh index 032cd0722..7db44749c 100755 --- a/app/build_grantlee_qt6.sh +++ b/app/build_grantlee_qt6.sh @@ -67,6 +67,19 @@ for p in Path('.').rglob('*'): except Exception as e: print('Skipping', p, 'error', e) +# remove explicit QT_TESTCASE_BUILDDIR compile definitions to avoid duplicate -D on command line +pat_qt_test_def = re.compile(r"^\s*target_compile_definitions\([^\n]*QT_TESTCASE_BUILDDIR[^\n]*\)\s*$", re.M) +for p in Path('.').rglob('*'): + if p.is_file() and p.name=='CMakeLists.txt': + try: + s = p.read_text() + s2 = pat_qt_test_def.sub(lambda m: '# PATCHED: removed QT_TESTCASE_BUILDDIR definition to avoid macro redefinition', s) + if s2 != s: + p.write_text(s2) + print('Removed QT_TESTCASE_BUILDDIR in', p) + except Exception as e: + print('Skipping', p, 'error', e) + # ensure files linking to Qt6::Test have a find_package(Qt6 Test REQUIRED) for p in Path('.').rglob('*'): if p.is_file() and (p.name=='CMakeLists.txt' or p.suffix=='.cmake'):