summaryrefslogtreecommitdiffstats
path: root/util/cmake/pro2cmake.py
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-07-12 16:54:26 +0200
committerLeander Beernaert <leander.beernaert@qt.io>2019-07-16 06:48:56 +0000
commitec1546afc4a5e417d37c6a14e2909b063045bf39 (patch)
tree8b4b2fddee330fdc2eaf4a86616a60cae02cafbc /util/cmake/pro2cmake.py
parent30b374637070581f04fc75287a32be943b00d422 (diff)
Handle TESTDATA for Qt Tests
These changes enable the support to handle test data and install or package them as resources when appropriate. This change does not handle the GENERATED_TESTDATA or TEST_HELPER_INSTALLS since there are very few occurrences of these and we can handle those as special cases. Finally, in add_qt_test, only append CMAKE_CURRENT_SOURCE_DIR if the path is not absolute. Change-Id: Ic20b9749d10e2a09916f2797606116471c64850b Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-xutil/cmake/pro2cmake.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 495c0e14ce..44768efa03 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -1590,12 +1590,32 @@ def write_main_part(cm_fh: typing.IO[str], name: str, typename: str,
# Now write out the scopes:
write_header(cm_fh, name, typename, indent=indent)
+ # collect all testdata and insert globbing commands
+ has_test_data = False
+ if typename == 'Test':
+ test_data = scope.expand('TESTDATA')
+ if test_data:
+ has_test_data = True
+ cm_fh.write('# Collect test data\n')
+ for data in test_data:
+ if data.endswith('*'):
+ cm_fh.write('{}file(GLOB test_data_glob \n{}LIST_DIRECTORIES'
+ ' true\n{}RELATIVE ${{CMAKE_CURRENT_SOURCE_DIR}}\n{}"{}")\n'\
+ .format(spaces(indent), spaces(indent + 1), \
+ spaces(indent + 1), spaces(indent + 1), data))
+ cm_fh.write('{}list(APPEND test_data ${{test_data_glob}})\n'.format(spaces(indent)))
+ else:
+ cm_fh.write('{}list(APPEND test_data "{}")\n'.format(spaces(indent), data))
+ cm_fh.write('\n')
+
cm_fh.write('{}{}({}\n'.format(spaces(indent), cmake_function, name))
for extra_line in extra_lines:
cm_fh.write('{} {}\n'.format(spaces(indent), extra_line))
write_sources_section(cm_fh, scopes[0], indent=indent, **kwargs)
+ if has_test_data:
+ cm_fh.write('{} TESTDATA ${{test_data}}\n'.format(spaces(indent)))
# Footer:
cm_fh.write('{})\n'.format(spaces(indent)))