diff --git a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp index b32ae13d9ab..1a1f9d57367 100644 --- a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp +++ b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp @@ -9,6 +9,7 @@ #include "cmakeproject.h" #include "cmakeprojectconstants.h" #include "cmaketool.h" +#include "cmaketoolmanager.h" #include #include @@ -197,12 +198,16 @@ IAssistProposal *CMakeFileCompletionAssist::performAsync() Project *project = nullptr; const FilePath &filePath = interface()->filePath(); if (!filePath.isEmpty() && filePath.isFile()) { + CMakeTool *cmake = nullptr; project = static_cast(ProjectManager::projectForFile(filePath)); - if (project && project->activeTarget()) { - CMakeTool *cmake = CMakeKitAspect::cmakeTool(project->activeTarget()->kit()); - if (cmake && cmake->isValid()) - keywords = cmake->keywords(); - } + if (project && project->activeTarget()) + cmake = CMakeKitAspect::cmakeTool(project->activeTarget()->kit()); + + if (!cmake) + cmake = CMakeToolManager::defaultCMakeTool(); + + if (cmake && cmake->isValid()) + keywords = cmake->keywords(); } QStringList buildTargets;