summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-04-08 18:34:00 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-04-08 21:58:41 +0200
commit0a13c3a3f0ef1eb7274badac000db9ec584faeca (patch)
tree6114f5e3a10ad2e5a28d371a815daea3e88044a7 /util
parent0651a4c27410ee48419a98985e6eea35c9f2a02b (diff)
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 <simon.hausmann@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-xutil/cmake/pro2cmake.py13
1 files changed, 12 insertions, 1 deletions
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)