CMake: Update code to decide whether to run cmake in fileapi mode

Change-Id: Iea841bb49876a580abc80cc7ea21a88b153cc224
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2019-06-21 14:14:31 +02:00
parent ea34cb2b4c
commit 09ae77d0a9
3 changed files with 33 additions and 6 deletions

View File

@@ -69,8 +69,7 @@ FileApiReader::FileApiReader()
&Core::EditorManager::aboutToSave,
this,
[this](const Core::IDocument *document) {
if (m_cmakeFiles.contains(document->filePath()) || !m_parameters.cmakeTool()
|| !m_parameters.cmakeTool()->isAutoRun()) {
if (m_cmakeFiles.contains(document->filePath())) {
qCDebug(cmakeFileApiMode) << "FileApiReader: DIRTY SIGNAL";
emit dirty();
}
@@ -139,9 +138,21 @@ void FileApiReader::parse(bool forceCMakeRun, bool forceConfiguration)
}
const QFileInfo replyFi = m_fileApi->scanForCMakeReplyFile();
const bool mustUpdate = forceCMakeRun || !replyFi.exists() || m_cmakeFiles.isEmpty()
|| anyOf(m_cmakeFiles, [&replyFi](const FilePath &f) {
return f.toFileInfo().lastModified() > replyFi.lastModified();
// Only need to update when one of the following conditions is met:
// * The user forces the update,
// * There is no reply file,
// * One of the cmakefiles is newer than the replyFile and the user asked
// for creator to run CMake as needed,
// * A query files are newer than the reply file
const bool mustUpdate = forceCMakeRun || !replyFi.exists()
|| (m_parameters.cmakeTool() && m_parameters.cmakeTool()->isAutoRun()
&& anyOf(m_cmakeFiles,
[&replyFi](const FilePath &f) {
return f.toFileInfo().lastModified()
> replyFi.lastModified();
}))
|| anyOf(m_fileApi->cmakeQueryFilePaths(), [&replyFi](const QString &qf) {
return QFileInfo(qf).lastModified() > replyFi.lastModified();
});
if (mustUpdate) {