Skip to content

Commit

Permalink
Do not set OUTPUT_DIRECTORY if it is already set
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Leander Beernaert committed Jan 16, 2020
1 parent 7c6f763 commit 99a824b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions util/cmake/pro2cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 99a824b

Please sign in to comment.