diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp index 54f28f7b2ad..bb58db95e36 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp @@ -44,6 +44,8 @@ CMakeListsNode::CMakeListsNode(const FilePath &cmakeListPath) : { setIcon(DirectoryIcon(Constants::Icons::FILE_OVERLAY)); setListInProject(false); + setLocationInfo( + {{Constants::CMAKE_LISTS_TXT, cmakeListPath.pathAppended(Constants::CMAKE_LISTS_TXT)}}); } bool CMakeListsNode::showInSimpleTree() const diff --git a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp index d65dbac18a2..640ae571759 100644 --- a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp +++ b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp @@ -112,10 +112,12 @@ static CMakeFileResult extractCMakeFilesData(const QFuture &cancelFuture, } auto node = std::make_unique(info.path, FileType::Project); - node->setIsGenerated(info.isGenerated - && !info.isCMakeListsDotTxt); // CMakeLists.txt are never - // generated, independent - // what cmake thinks:-) + node->setIsGenerated(info.isGenerated); + + // We will have the CMakeLists.txt file in the Target nodes as a child node. + // Except the root CMakeLists.txt file. + if (info.isCMakeListsDotTxt && info.path.parentDir() != sourceDirectory) + node->setIsGenerated(true); if (info.isCMakeListsDotTxt) { result.cmakeListNodes.emplace_back(std::move(node)); @@ -938,6 +940,14 @@ static void setupLocationInfoForTargets(const QFuture &cancelFuture, result += dedupMulti(t.installDefinitions); folderNode->setLocationInfo(result); + + if (!t.backtrace.isEmpty() && t.targetType != TargetType::UtilityType) { + auto cmakeDefinition = std::make_unique( + t.backtrace.last().path, Node::fileTypeForFileName(t.backtrace.last().path)); + cmakeDefinition->setLine(t.backtrace.last().line); + cmakeDefinition->setPriority(Node::DefaultProjectFilePriority); + folderNode->addNode(std::move(cmakeDefinition)); + } } } }