diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2023-09-15 16:48:48 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2023-09-20 17:16:28 +0200 |
commit | d3c6d40d5d949deb77668af696ea1b07036eb61d (patch) | |
tree | 21446e7bc12dfe3ced928f6fc41485437354dfbd /cmake/QtTestHelpers.cmake | |
parent | 1d89f6602aae6bc826d846bc5889a71ea4dd7e66 (diff) |
CMake: Handle subdirectory test data installation
The qt_install() calls in qt_internal_add_test() did not re-create
subdirectories that are part of the input test data.
Make sure that the subdirectories are created upon installation by
ensuring we specify a relative installation path that includes all the
path parts except for the file name.
That works the same for directories.
Amends ec1546afc4a5e417d37c6a14e2909b063045bf39
Amends 540bd6cf203969363e641027b66fb044d9ccb1f6
Amends 1307736c7db1ff24e3b8282f4a7b14d24866feba
Amends 0a1256a52d8c6c1b85a10f7dc94dfc34e3540040
Task-number: QTBUG-117098
Change-Id: Ia80f4e7e1ec531264864bcde3ac192ce79b65746
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'cmake/QtTestHelpers.cmake')
-rw-r--r-- | cmake/QtTestHelpers.cmake | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake index b2ef4e58a6..babfd77a98 100644 --- a/cmake/QtTestHelpers.cmake +++ b/cmake/QtTestHelpers.cmake @@ -782,15 +782,27 @@ function(qt_internal_add_test name) endif() endif() else() - # Install test data - file(RELATIVE_PATH relative_path_to_test_project - "${QT_TOP_LEVEL_SOURCE_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}") - qt_path_join(testdata_install_dir ${QT_INSTALL_DIR} - "${relative_path_to_test_project}") - if (testdata_install_dir) + # Install test data, when tests are built in-tree or as standalone tests, but not as a + # single standalone test, which is checked by the existence of the QT_TOP_LEVEL_SOURCE_DIR + # variable. + # TODO: Shouldn't we also handle the single standalone test case? + # TODO: Does installing even makes sense, given where QFINDTESTDATA looks for installed + # test data, and where we end up installing it? See QTBUG-117098. + if(QT_TOP_LEVEL_SOURCE_DIR) foreach(testdata IN LISTS arg_TESTDATA) set(testdata "${CMAKE_CURRENT_SOURCE_DIR}/${testdata}") + + # Get the relative source dir for each test data entry, because it might contain a + # subdirectory. + file(RELATIVE_PATH relative_path_to_test_project + "${QT_TOP_LEVEL_SOURCE_DIR}" + "${testdata}") + get_filename_component(relative_path_to_test_project + "${relative_path_to_test_project}" DIRECTORY) + + qt_path_join(testdata_install_dir ${QT_INSTALL_DIR} + "${relative_path_to_test_project}") + if (IS_DIRECTORY "${testdata}") qt_install( DIRECTORY "${testdata}" |