diff --git a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp index 951847397c4..abdd419a0c0 100644 --- a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp +++ b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp @@ -53,7 +53,7 @@ using namespace CMakeProjectManager::Internal::FileApiDetails; class CMakeFileResult { public: - QSet cmakeFiles; + QSet cmakeFiles; std::vector> cmakeNodesSource; std::vector> cmakeNodesBuild; @@ -61,7 +61,7 @@ public: std::vector> cmakeListNodes; }; -CMakeFileResult extractCMakeFilesData(const std::vector &cmakefiles, +CMakeFileResult extractCMakeFilesData(const std::vector &cmakefiles, const FilePath &sourceDirectory, const FilePath &buildDirectory) { @@ -72,9 +72,11 @@ CMakeFileResult extractCMakeFilesData(const std::vector cmakeFiles; + QSet cmakeFiles; std::vector> cmakeNodesSource; std::vector> cmakeNodesBuild; diff --git a/src/plugins/cmakeprojectmanager/fileapidataextractor.h b/src/plugins/cmakeprojectmanager/fileapidataextractor.h index bd57e194664..f42cc27d410 100644 --- a/src/plugins/cmakeprojectmanager/fileapidataextractor.h +++ b/src/plugins/cmakeprojectmanager/fileapidataextractor.h @@ -44,12 +44,26 @@ namespace Internal { class FileApiData; +class CMakeFileInfo +{ +public: + bool operator==(const CMakeFileInfo& other) const { return path == other.path; } + + Utils::FilePath path; + bool isCMake = false; + bool isCMakeListsDotTxt = false; + bool isExternal = false; + bool isGenerated = false; +}; + +inline uint qHash(const CMakeFileInfo &info, uint seed = 0) { return info.path.hash(seed); } + class FileApiQtcData { public: QString errorMessage; CMakeConfig cache; - QSet cmakeFiles; + QSet cmakeFiles; QList buildTargets; ProjectExplorer::RawProjectParts projectParts; std::unique_ptr rootProjectNode; diff --git a/src/plugins/cmakeprojectmanager/fileapiparser.cpp b/src/plugins/cmakeprojectmanager/fileapiparser.cpp index c2942b02ddf..dd02e3cc337 100644 --- a/src/plugins/cmakeprojectmanager/fileapiparser.cpp +++ b/src/plugins/cmakeprojectmanager/fileapiparser.cpp @@ -249,10 +249,10 @@ static std::vector readCMakeFilesFile(const FilePath &cmakeFilesF for (const QJsonValue &v : inputs) { CMakeFileInfo info; const QJsonObject input = v.toObject(); - info.path = input.value("path").toString(); + info.path = FilePath::fromString(input.value("path").toString()); info.isCMake = input.value("isCMake").toBool(); - const QString filename = FilePath::fromString(info.path).fileName(); + const QString filename = info.path.fileName(); info.isCMakeListsDotTxt = (filename.compare("CMakeLists.txt", HostOsInfo::fileNameCaseSensitivity()) == 0); diff --git a/src/plugins/cmakeprojectmanager/fileapiparser.h b/src/plugins/cmakeprojectmanager/fileapiparser.h index dc018a7c62c..1f6875ff8eb 100644 --- a/src/plugins/cmakeprojectmanager/fileapiparser.h +++ b/src/plugins/cmakeprojectmanager/fileapiparser.h @@ -71,16 +71,6 @@ public: Utils::FilePath jsonFile(const QString &kind, const Utils::FilePath &replyDir) const; }; -class CMakeFileInfo -{ -public: - QString path; - bool isCMake = false; - bool isCMakeListsDotTxt = false; - bool isExternal = false; - bool isGenerated = false; -}; - class Directory { public: @@ -243,7 +233,7 @@ class FileApiData public: FileApiDetails::ReplyFileContents replyFile; CMakeConfig cache; - std::vector cmakeFiles; + std::vector cmakeFiles; FileApiDetails::Configuration codemodel; std::vector targetDetails; }; diff --git a/src/plugins/cmakeprojectmanager/fileapireader.cpp b/src/plugins/cmakeprojectmanager/fileapireader.cpp index 18ec80651c3..09aa375bd24 100644 --- a/src/plugins/cmakeprojectmanager/fileapireader.cpp +++ b/src/plugins/cmakeprojectmanager/fileapireader.cpp @@ -88,8 +88,12 @@ void FileApiReader::setParameters(const BuildDirParameters &p) void FileApiReader::resetData() { m_cmakeFiles.clear(); - if (!m_parameters.sourceDirectory.isEmpty()) - m_cmakeFiles.insert(m_parameters.sourceDirectory.pathAppended("CMakeLists.txt")); + if (!m_parameters.sourceDirectory.isEmpty()) { + CMakeFileInfo cmakeListsTxt; + cmakeListsTxt.path = m_parameters.sourceDirectory.pathAppended("CMakeLists.txt"); + cmakeListsTxt.isCMakeListsDotTxt = true; + m_cmakeFiles.insert(cmakeListsTxt); + } m_cache.clear(); m_buildTargets.clear(); @@ -124,8 +128,9 @@ void FileApiReader::parse(bool forceCMakeRun, const bool hasArguments = !args.isEmpty(); const bool replyFileMissing = !replyFile.exists(); const bool cmakeFilesChanged = m_parameters.cmakeTool() && m_parameters.cmakeTool()->isAutoRun() - && anyOf(m_cmakeFiles, [&replyFile](const FilePath &f) { - return f.lastModified() > replyFile.lastModified(); + && anyOf(m_cmakeFiles, [&replyFile](const CMakeFileInfo &info) { + return !info.isGenerated + && info.path.lastModified() > replyFile.lastModified(); }); const bool queryFileChanged = anyOf(FileApiParser::cmakeQueryFilePaths(m_parameters.buildDirectory), [&replyFile](const FilePath &qf) { @@ -175,7 +180,10 @@ bool FileApiReader::isParsing() const QSet FileApiReader::projectFilesToWatch() const { - return m_cmakeFiles; + return Utils::transform( + Utils::filtered(m_cmakeFiles, + [](const CMakeFileInfo &info) { return !info.isGenerated; }), + [](const CMakeFileInfo &info) { return info.path;}); } QList FileApiReader::takeBuildTargets(QString &errorMessage){ @@ -249,7 +257,7 @@ void FileApiReader::endState(const FilePath &replyFilePath) const FilePath sourceDirectory = m_parameters.sourceDirectory; const FilePath buildDirectory = m_parameters.buildDirectory; - const FilePath topCmakeFile = m_cmakeFiles.size() == 1 ? *m_cmakeFiles.begin() : FilePath{}; + const FilePath topCmakeFile = m_cmakeFiles.size() == 1 ? (*m_cmakeFiles.begin()).path : FilePath{}; const QString cmakeBuildType = m_parameters.cmakeBuildType == "Build" ? "" : m_parameters.cmakeBuildType; QTC_CHECK(!replyFilePath.needsDevice()); diff --git a/src/plugins/cmakeprojectmanager/fileapireader.h b/src/plugins/cmakeprojectmanager/fileapireader.h index 3961dfc3b97..4e447966990 100644 --- a/src/plugins/cmakeprojectmanager/fileapireader.h +++ b/src/plugins/cmakeprojectmanager/fileapireader.h @@ -28,6 +28,7 @@ #include "cmakebuildtarget.h" #include "cmakeprocess.h" #include "cmakeprojectnodes.h" +#include "fileapidataextractor.h" #include #include @@ -100,7 +101,7 @@ private: // cmake data: CMakeConfig m_cache; - QSet m_cmakeFiles; + QSet m_cmakeFiles; QList m_buildTargets; ProjectExplorer::RawProjectParts m_projectParts; std::unique_ptr m_rootProjectNode;