cmake: resolve symlinks when comparing source directories.

Testcase: trying to use an existing build dir which was
made for /d/foo where /d is a symlink to $HOME/d.

To help understanding the problem, the error message now prints
both source dirs, the one found in the builddir and the one we expected.

Change-Id: I9a24fbd6ef3cf8108c5edba0d2a5b99ecdea0e89
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
David Faure
2016-06-18 15:11:12 +02:00
parent ff2ba0cef5
commit 52ed384549
3 changed files with 24 additions and 5 deletions

View File

@@ -286,8 +286,12 @@ CMakeConfig BuildDirManager::parsedConfiguration() const
emit errorOccured(errorMessage);
const Utils::FileName sourceOfBuildDir
= Utils::FileName::fromUtf8(CMakeConfigItem::valueOf("CMAKE_HOME_DIRECTORY", m_cmakeCache));
if (sourceOfBuildDir != sourceDirectory()) // Use case-insensitive compare where appropriate
emit errorOccured(tr("The build directory is not for %1").arg(sourceDirectory().toUserOutput()));
const Utils::FileName canonicalSourceOfBuildDir = Utils::FileUtils::canonicalPath(sourceOfBuildDir);
const Utils::FileName canonicalSourceDirectory = Utils::FileUtils::canonicalPath(sourceDirectory());
if (canonicalSourceOfBuildDir != canonicalSourceDirectory) // Uses case-insensitive compare where appropriate
emit errorOccured(tr("The build directory is not for %1 but for %2")
.arg(canonicalSourceOfBuildDir.toUserOutput(),
canonicalSourceDirectory.toUserOutput()));
}
return m_cmakeCache;
}