diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 5b6b3847d8b..71053d288b7 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -779,7 +779,12 @@ class QmakeParser: expr.setDebug() Grammar = StatementGroup('statements') - Grammar.ignore(pp.pythonStyleComment()) + + # Ignore comment lines, including the final line break, + # otherwise parsing fails when looking at multi line assignments + # with comments in between. + Comment = pp.Regex(r"#.*\n").setName("qmake style comment") + Grammar.ignore(Comment()) return Grammar diff --git a/util/cmake/tests/data/lc_with_comment.pro b/util/cmake/tests/data/lc_with_comment.pro new file mode 100644 index 00000000000..c087dadacc1 --- /dev/null +++ b/util/cmake/tests/data/lc_with_comment.pro @@ -0,0 +1,4 @@ +SUBDIRS = \ +# dds \ + tga \ + wbmp diff --git a/util/cmake/tests/test_parsing.py b/util/cmake/tests/test_parsing.py index 79ad0a49454..4b6f48b931e 100755 --- a/util/cmake/tests/test_parsing.py +++ b/util/cmake/tests/test_parsing.py @@ -305,3 +305,7 @@ def test_realworld_lc(): result = parse_file(_tests_path + '/data/lc.pro') assert len(result) == 3 + +def test_realworld_lc_with_comment_in_between(): + result = parse_file(_tests_path + '/data/lc_with_comment.pro') + assert len(result) == 1