CMake: pro2cmake.py: Work on mapping of conditions to cmake

Make sure complex things in qmake (e.g. function calls, etc.) are
mapped better to cmake. When there is no way to properly map the
qmake construct, then make sure to map everything into one
identifier.

This is to keep the structure of the condition simple.

Change-Id: I6d88e0cb85fce1041bbfdc96604dab7bd4e65856
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Tobias Hunger 2019-01-23 12:57:06 +01:00
parent 404d0b5975
commit aee1d1e96b

View File

@ -517,6 +517,14 @@ def parseProFile(file: str, *, debug=False):
def map_condition(condition: str) -> str:
re.sub(r"\bif\s*\((.*?)\)", r"\1", condition)
re.sub(r"\bisEmpty\s*\((.*?)\)", r"\1 STREQUAL \"\"", condition)
re.sub(r"\bcontains\s*\((.*?), (.*)?\)", r"\1___contains___\2", condition)
condition = condition.replace('*', '_x_')
condition = condition.replace('.$$', '__ss_')
condition = condition.replace('$$', '_ss_')
condition = condition.replace('!', 'NOT ')
condition = condition.replace('&&', ' AND ')
condition = condition.replace('|', ' OR ')