From 99a824bbb74aa88a16a8c7b483e1ca599dd66d4f Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Thu, 16 Jan 2020 09:29:29 +0100 Subject: Do not set OUTPUT_DIRECTORY if it is already set This can happen in unit tests where a test has TARGET set to "../name", which requires the target to placed in the parent binary directory. It is possible to run into a second assignment for OUTPUT_DIRECTORY via the DESTDIR property (e.g: qdbushmarshall test) which can then result in two OUTPUT_DIRECTORY values. However, the first one needs to take precedence or the tests won't execute properly. Change-Id: Ib263843fa86c3dd68d92a0989b95f2890335c92d Reviewed-by: Alexandru Croitor --- util/cmake/pro2cmake.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'util') diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 97f92d7614..ffb36324cd 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -2710,8 +2710,14 @@ def write_main_part( # Check for DESTDIR override destdir = scope.get_string("DESTDIR") if destdir: - destdir = replace_path_constants(destdir, scope) - extra_lines.append(f'OUTPUT_DIRECTORY "{destdir}"') + already_added = False + for line in extra_lines: + if line.startswith("OUTPUT_DIRECTORY"): + already_added = True + break + if not already_added: + destdir = replace_path_constants(destdir, scope) + extra_lines.append(f'OUTPUT_DIRECTORY "{destdir}"') cm_fh.write(f"{spaces(indent)}{cmake_function}({name}\n") for extra_line in extra_lines: -- cgit v1.2.3