Fix cases where DESTDIR equals ./ or ../

When DESTDIR has relative paths as a parameter we should prefix those
with ${CMAKE_CURRENT_BINARY_DIR} in order for them to be placed in
the correct location.

Change-Id: Ie9e9d656cbb54457bdf99425e3e1b05e09f20d7c
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Leander Beernaert 2019-08-09 15:20:19 +02:00
parent 6ef1b60b08
commit 3549f51c98

View File

@ -1865,6 +1865,8 @@ def write_main_part(cm_fh: typing.IO[str], name: str, typename: str,
# Check for DESTDIR override
destdir = scope.get_string('DESTDIR')
if destdir:
if destdir.startswith('./') or destdir.startswith('../'):
destdir = '${CMAKE_CURRENT_BINARY_DIR}/' + destdir
extra_lines.append('OUTPUT_DIRECTORY "{}"'.format(destdir))
cm_fh.write('{}{}({}\n'.format(spaces(indent), cmake_function, name))