QMake searches a .qmake.conf file to determine the source root of the
project, and a .qmake.cache to determine the build root.
If a .qmake.conf exists but no .qmake.cache in the build directory is
found, a build root would be set that is only valid if the build
directory is at the same depth as the source directory.
The invalid build root resulted in the creation of .qmake.cache files
at "interesting" locations (e.g. high up in the directory tree), a
potential cause for even more interesting build failures in the
future.
Fix this by splitting up the loop that determined build and source
root. Both are now determined independently of each other.
Fixes: QTBUG-76140
Change-Id: Ib5c922b87879fcf2f076298a69abcdbc4e8587b3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>