diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2018-12-20 10:41:56 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2018-12-21 10:24:01 +0000 |
commit | f0aa8fa48e3fbd601d983d809a38945f2814665e (patch) | |
tree | 365b099ebb268cea8ab7f468fe4d75d4f123db07 /util | |
parent | 99315c21291e72c1280093c0d8f47241818df57a (diff) |
pro2cmake: Handle VPATH
Change-Id: Ia72f55489129c50ca730c42b75bbc2bda926b82f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-x | util/cmake/pro2cmake.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 40043d15d5..f740b4353f 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -81,7 +81,7 @@ def map_to_file(f: str, top_dir: str, current_dir: str, return f -def map_source_to_cmake(source: str) -> typing.Optional[str]: +def map_source_to_cmake(source: str, base_dir: str, vpath: List[str]) -> typing.Optional[str]: if not source or source == '$$NO_PCH_SOURCES': return None if source.startswith('$$PWD/'): @@ -90,7 +90,19 @@ def map_source_to_cmake(source: str) -> typing.Optional[str]: return "${CMAKE_CURRENT_SOURCE_DIR}" if source.startswith('$$QT_SOURCE_TREE/'): return "${PROJECT_SOURCE_DIR}/" + source[17:] - return source + + if os.path.exists(os.path.join(base_dir, source)): + return source + + + for v in vpath: + fullpath = os.path.join(v, source) + if os.path.exists(fullpath): + relpath = os.path.relpath(fullpath, base_dir) + return relpath + + print(' XXXX: Source {}: Not found.'.format(source)) + return '{}-NOTFOUND'.format(source) def map_source_to_fs(base_dir: str, file: str, source: str) -> typing.Optional[str]: @@ -492,7 +504,9 @@ def write_sources_section(cm_fh: IO[str], scope: Scope, *, indent: int=0, else: sources += resources - sources = [map_source_to_cmake(s) for s in sources] + vpath = scope.get('VPATH') + + sources = [map_source_to_cmake(s, scope.basedir(), vpath) for s in sources] if sources: cm_fh.write('{} SOURCES\n'.format(ind)) for l in sort_sources(sources): |