diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2023-12-08 16:35:14 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-12-15 14:25:11 +0000 |
commit | fa3c1a02053191890a881b887e0bb3a0fe7b65ed (patch) | |
tree | a08080552fe1cb550df9cf3500f72133e896b40c /cmake | |
parent | 6c43c86f6b9621552907174e6c58b4a8c2d27219 (diff) |
CMake: Don't recurse with qt-cmake-standalone-test in-source dirs
When the qt-cmake-standalone-test root project is configured in-source
in the source directory of a test A, where test A ends up being added
via add_subdirectory(A), this causes the SUBDIRECTORIES property of A
to contain itself for some reason.
Recursively iterating over the root project's subdirectories thus
causes an endless recursion.
Make sure to remove the currently processed directory from the
retrieved SUBDIRECTORIES property when the function is called
during qt-cmake-standalone-test configuration.
We limit it just for that script, so that we don't accidentally
increase the configure time when building all standalone tests, and
call list(REMOVE_ITEM) too many times.
Upstream issue filed at
https://gitlab.kitware.com/cmake/cmake/-/issues/25489
In a way, amends d08fa86e63448377dde4297bc94680a9d7daaaeb because it
exposed the issue.
Amends 1c82e92202c8c359872c08095670c121602094b8
Pick-to: 6.5
Task-number: QTBUG-119998
Change-Id: I6f92a07be105cde74ac4946523967791db7bf301
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 04a327f00a84b0c13cb4a4a6715b2ce86ea9f61a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit e16db6933c09245e8f5b31cc4489d9e8d7bab9b5)
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtPublicCMakeHelpers.cmake | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cmake/QtPublicCMakeHelpers.cmake b/cmake/QtPublicCMakeHelpers.cmake index a3a6c9d71c..23a10db7bc 100644 --- a/cmake/QtPublicCMakeHelpers.cmake +++ b/cmake/QtPublicCMakeHelpers.cmake @@ -117,6 +117,18 @@ function(_qt_internal_collect_buildsystem_targets result dir) endif() get_property(subdirs DIRECTORY "${dir}" PROPERTY SUBDIRECTORIES) + + # Make sure that we don't hit endless recursion when running qt-cmake-standalone-test on a + # in-source test dir, where the currently processed directory lists itself in its SUBDIRECTORIES + # property. + # See https://bugreports.qt.io/browse/QTBUG-119998 + # and https://gitlab.kitware.com/cmake/cmake/-/issues/25489 + # Do it only when QT_INTERNAL_IS_STANDALONE_TEST is set, to avoid the possible slowdown when + # processing many subdirectores when configuring all standalone tests rather than just one. + if(QT_INTERNAL_IS_STANDALONE_TEST) + list(REMOVE_ITEM subdirs "${dir}") + endif() + foreach(subdir IN LISTS subdirs) _qt_internal_collect_buildsystem_targets(${result} "${subdir}" ${forward_args}) endforeach() |