From 0a13c3a3f0ef1eb7274badac000db9ec584faeca Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 8 Apr 2020 18:34:00 +0200 Subject: CMake: pro2cmake: Handle $$PWD in included .pri files correct-ish Previously the $$PWD was evaluated within the including .pro file, which generated incorrect relative paths to source files. Now we use a horrible hack to evaluate keys ending with SOURCES and HEADERS. If such is a case, use a map_file transformer which will use the included scope, thus creating correct relative paths. Fixes projects in qtdeclarative like src/qmltypregistrar and qmllint. Checked that it doesn't break projects in qtdeclarative and qtbase. Change-Id: I21f1e4c638c2cf8d0f67e94e1a583ebc54c175a2 Reviewed-by: Simon Hausmann --- util/cmake/pro2cmake.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'util/cmake/pro2cmake.py') diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index ae46277293..87e2593d00 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -1285,7 +1285,18 @@ class Scope(object): else: return [f"${{CMAKE_CURRENT_BINARY_DIR}}/{relative_path}"] - return self._evalOps(key, None, [], inherit=inherit) + # Horrible hack. If we're returning the values for some key + # that looks like source or header files, make sure to use a + # map_files transformer, so that $$PWD values are evaluated + # in the transformer scope, otherwise relative paths will be + # broken. + # Looking at you qmltyperegistrar.pro. + eval_ops_transformer = None + if key.endswith("SOURCES") or key.endswith("HEADERS"): + def file_transformer(scope, files): + return scope._map_files(files) + eval_ops_transformer = file_transformer + return self._evalOps(key, eval_ops_transformer, [], inherit=inherit) def get_string(self, key: str, default: str = "", inherit: bool = False) -> str: v = self.get(key, inherit=inherit) -- cgit v1.2.3