diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 1f76d9dedd8..06d0c925d92 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -568,11 +568,13 @@ class QmakeParser: + pp.nestedExpr(opener='{', closer='}', ignoreExpr=pp.LineEnd())) # ignore the whole thing... ForLoop = pp.Suppress(pp.Keyword('for') + CallArgs + pp.nestedExpr(opener='{', closer='}', ignoreExpr=pp.LineEnd())) # ignore the whole thing... + ForLoopSingleLine = pp.Suppress(pp.Keyword('for') + CallArgs + + pp.Literal(':') + pp.SkipTo(EOL, ignore=LC)) # ignore the whole thing... FunctionCall = pp.Suppress(Identifier + pp.nestedExpr()) Scope = pp.Forward() - Statement = pp.Group(Load | Include | Option | ForLoop \ + Statement = pp.Group(Load | Include | Option | ForLoop | ForLoopSingleLine \ | DefineTestDefinition | FunctionCall | Operation) StatementLine = Statement + (EOL | pp.FollowedBy('}')) StatementGroup = pp.ZeroOrMore(StatementLine | Scope | pp.Suppress(EOL)) diff --git a/util/cmake/tests/data/single_line_for.pro b/util/cmake/tests/data/single_line_for.pro new file mode 100644 index 00000000000..806d08a49cf --- /dev/null +++ b/util/cmake/tests/data/single_line_for.pro @@ -0,0 +1,4 @@ +for(d, sd): \ + exists($$d/$${d}.pro): \ + SUBDIRS += $$d + diff --git a/util/cmake/tests/test_parsing.py b/util/cmake/tests/test_parsing.py index dd4e5508f60..2f227e0ba26 100755 --- a/util/cmake/tests/test_parsing.py +++ b/util/cmake/tests/test_parsing.py @@ -180,6 +180,12 @@ def test_for(): assert result[1] == [] +def test_single_line_for(): + result = parse_file(_tests_path + '/data/single_line_for.pro') + assert len(result) == 1 + assert result[0] == [] + + def test_unset(): result = parse_file(_tests_path + '/data/unset.pro') assert len(result) == 1