build(grantlee): map find_package(Qt5 Test) -> find_package(Qt6 Test REQUIRED) to ensure Qt6::Test is available when tests link
This commit is contained in:
1 parent
92888ddd8d
commit
a2931cb186
1 file changed
+3
@@ -31,11 +31,14 @@ 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)
|
||||
# map find_package(Qt5 Test) forms to Qt6 Test
|
||||
pat_test_simple = re.compile(r'find_package\s*\(\s*Qt5\s+Test(?:\s+REQUIRED)?\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)
|
||||
s2 = pat_test_simple.sub('find_package(Qt6 Test REQUIRED)', s2)
|
||||
if s2 != s:
|
||||
p.write_text(s2)
|
||||
print('Patched find_package components in', p)
|
||||
|
||||
Reference in new issue
Block a user