Commit 543929cd authored by Tobias Hunger's avatar Tobias Hunger

CMake: Warn when doing out-of-source builds with in-source configuration

Warn when attempting to do an out-of-source build while an in-source build
is configured. This seems to confuse cmake.

Task-number: QTCREATORBUG-18381
Change-Id: I1abd3be4129ba5af6439dcd60d16d429b93c0382
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent c0c210cb
......@@ -217,6 +217,22 @@ bool CMakeBuildStep::init(QList<const BuildStep *> &earlierSteps)
return false;
}
// Warn if doing out-of-source builds with a CMakeCache.txt is the source directory
const Utils::FileName projectDirectory = bc->target()->project()->projectDirectory();
if (bc->buildDirectory() != projectDirectory) {
Utils::FileName cmc = projectDirectory;
cmc.appendPath("CMakeCache.txt");
if (cmc.exists()) {
emit addTask(Task(Task::Warning,
tr("There is a CMakeCache.txt file in \"%1\", which suggest an "
"in-source build was done before. You are now building in \"%2\", "
"and the CMakeCache.txt file might confuse CMake.")
.arg(projectDirectory.toUserOutput(), bc->buildDirectory().toUserOutput()),
Utils::FileName(), -1,
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
}
}
QString arguments = allArguments(rc);
setIgnoreReturnValue(m_buildTarget == CMakeBuildStep::cleanTarget());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment