diff --git a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp index 6dc754d2bed..2f7313c4a45 100644 --- a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp +++ b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp @@ -314,7 +314,9 @@ static void updateCMakeConfigurationWithLocalData(CMakeConfig &cmakeCache, return var == "CMAKE_PREFIX_PATH" || var == "CMAKE_MODULE_PATH"; }; - const FilePath projectDir = ProjectTree::currentBuildSystem()->projectDirectory(); + const FilePath projectDir = ProjectTree::currentBuildSystem() + ? ProjectTree::currentBuildSystem()->projectDirectory() + : currentDir; auto updateDirVariables = [currentDir, projectDir, cmakeCache](QByteArray &value) { value.replace("${CMAKE_CURRENT_SOURCE_DIR}", currentDir.path().toUtf8()); value.replace("${CMAKE_CURRENT_LIST_DIR}", currentDir.path().toUtf8());