From ee5d7facc14a4d91475ac5e95dba5f346ee3f880 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Tue, 14 Jan 2020 13:30:12 +0100 Subject: [PATCH] Adjust OUTPUT_DIRECTORY for tests when targets starts with ../ Automatically insert OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../ for each tests that has a target name which starts with ../. To do so we added the TARGET_ORIGINAL property which does not remove the ../ from the target name. Change-Id: I55ba1385aa160610a0ff80ed56ff37a80c3590fa Reviewed-by: Alexandru Croitor --- util/cmake/pro2cmake.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 8378cd62287..97f92d76142 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -1369,6 +1369,10 @@ class Scope(object): target = self.expandString("TARGET") or os.path.splitext(os.path.basename(self.file))[0] return re.sub(r"\.\./", "", target) + @property + def TARGET_ORIGINAL(self) -> str: + return self.expandString("TARGET") or os.path.splitext(os.path.basename(self.file))[0] + @property def _INCLUDED(self) -> List[str]: return self.get("_INCLUDED") @@ -2904,6 +2908,10 @@ def write_test(cm_fh: IO[str], scope: Scope, gui: bool = False, *, indent: int = for path in importpath: extra.append(f' "{path}"') + target_original = scope.TARGET_ORIGINAL + if target_original and target_original.startswith("../"): + extra.append("OUTPUT_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}/../\"") + requires_content = expand_project_requirements(scope, skip_message=True) if requires_content: requires_content += "\n"