Index: plugins/cmake/cmakebuilddirchooser.cpp =================================================================== --- plugins/cmake/cmakebuilddirchooser.cpp +++ plugins/cmake/cmakebuilddirchooser.cpp @@ -298,7 +298,7 @@ if (index > 0) { Q_ASSERT(m_project); m_chooserUi->cmakeExecutable->setUrl(CMake::currentCMakeExecutable(m_project, index -1).toUrl()); - m_chooserUi->buildFolder->setUrl(CMake::currentBuildDir(m_project, index -1).toUrl()); + m_chooserUi->buildFolder->setUrl(CMake::currentBuildDir(m_project, false, index -1).toUrl()); m_chooserUi->installPrefix->setUrl(CMake::currentInstallDir(m_project, index -1).toUrl()); m_chooserUi->buildType->setCurrentText(CMake::currentBuildType(m_project, index -1)); m_chooserUi->extraArguments->setCurrentText(CMake::currentExtraArguments(m_project, index -1)); Index: plugins/cmake/cmakecommitchangesjob.cpp =================================================================== --- plugins/cmake/cmakecommitchangesjob.cpp +++ plugins/cmake/cmakecommitchangesjob.cpp @@ -162,7 +162,7 @@ QString dir = m_path.toLocalFile(); if(data.vm.value("CMAKE_INCLUDE_CURRENT_DIR")==QStringList("ON")) { m_directories += dir; - m_directories += CMakeParserUtils::binaryPath(dir, m_project->path().toLocalFile(), CMake::currentBuildDir(m_project).toLocalFile(QUrl::RemoveTrailingSlash)); + m_directories += CMakeParserUtils::binaryPath(dir, m_project->path().toLocalFile(), CMake::currentBuildDir(m_project, true).toLocalFile(QUrl::RemoveTrailingSlash)); } m_directories += resolvePaths(m_path, data.properties[DirectoryProperty][dir]["INCLUDE_DIRECTORIES"]); m_directories.removeAll(QString()); Index: plugins/cmake/cmakeimportjsonjob.cpp =================================================================== --- plugins/cmake/cmakeimportjsonjob.cpp +++ plugins/cmake/cmakeimportjsonjob.cpp @@ -94,7 +94,7 @@ ret.includes = kTransform(result.paths, convert); ret.frameworkDirectories = kTransform(result.frameworkDirectories, convert); ret.defines = result.defines; - const Path path(rt->pathInHost(Path(entry[KEY_FILE].toString()))); + const Path path(rt->pathInHost(Path((QFileInfo(entry[KEY_FILE].toString()).canonicalFilePath())))); qCDebug(CMAKE) << "entering..." << path << entry[KEY_FILE]; data.files[path] = ret; } @@ -142,7 +142,7 @@ return; } - const Path currentBuildDir = CMake::currentBuildDir(m_project); + const Path currentBuildDir = CMake::currentBuildDir(m_project, true); Q_ASSERT (!currentBuildDir.isEmpty()); const Path targetsFilePath = CMake::targetDirectoriesFile(m_project); Index: plugins/cmake/cmakemanager.cpp =================================================================== --- plugins/cmake/cmakemanager.cpp +++ plugins/cmake/cmakemanager.cpp @@ -128,7 +128,7 @@ // if(fi) // ret.addPath(fi->buildDir()); // return ret; - return Path(CMake::currentBuildDir(item->project())); + return Path(CMake::currentBuildDir(item->project(), true)); } KDevelop::ProjectFolderItem* CMakeManager::import( KDevelop::IProject *project ) Index: plugins/cmake/cmakemodelitems.cpp =================================================================== --- plugins/cmake/cmakemodelitems.cpp +++ plugins/cmake/cmakemodelitems.cpp @@ -32,7 +32,7 @@ if (!m_builtUrl.isEmpty()) return m_builtUrl.toUrl(); - const KDevelop::Path buildDir = CMake::currentBuildDir(project()); + const KDevelop::Path buildDir = CMake::currentBuildDir(project(), true); if (buildDir.isEmpty()) return QUrl(); Index: plugins/cmake/cmakeserverimportjob.cpp =================================================================== --- plugins/cmake/cmakeserverimportjob.cpp +++ plugins/cmake/cmakeserverimportjob.cpp @@ -163,7 +163,8 @@ { connect(m_server.data(), &CMakeServer::response, this, &CMakeServerImportJob::processResponse); - m_server->handshake(m_project->path(), CMake::currentBuildDir(m_project)); + // maybe use the canonical project path too? + m_server->handshake(m_project->path(), CMake::currentBuildDir(m_project, true)); } void CMakeServerImportJob::processResponse(const QJsonObject& response) Index: plugins/cmake/cmakeutils.h =================================================================== --- plugins/cmake/cmakeutils.h +++ plugins/cmake/cmakeutils.h @@ -86,7 +86,7 @@ * @returns the current builddir for the given project or an empty url if none * has been set by the user. */ - KDEVCMAKECOMMON_EXPORT KDevelop::Path currentBuildDir( KDevelop::IProject* project, int builddir = -1 ); + KDEVCMAKECOMMON_EXPORT KDevelop::Path currentBuildDir( KDevelop::IProject* project, bool canonical=false, int builddir = -1 ); /** * @returns the path to the 'compile_commands.json' file in the current builddir for the given project @@ -188,7 +188,7 @@ /** * Retrieves the configured build directories for @p project. */ - KDEVCMAKECOMMON_EXPORT QStringList allBuildDirs(KDevelop::IProject* project); + KDEVCMAKECOMMON_EXPORT QStringList allBuildDirs(KDevelop::IProject* project, bool canonical=false); /** * Attempts to migrate the CMake configuration to per-builddir format. Index: plugins/cmake/cmakeutils.cpp =================================================================== --- plugins/cmake/cmakeutils.cpp +++ plugins/cmake/cmakeutils.cpp @@ -165,7 +165,7 @@ KDevelop::Path::List resolveSystemDirs(KDevelop::IProject* project, const QStringList& dirs) { - const KDevelop::Path buildDir(CMake::currentBuildDir(project)); + const KDevelop::Path buildDir(CMake::currentBuildDir(project, true)); const KDevelop::Path installDir(CMake::currentInstallDir(project)); KDevelop::Path::List newList; @@ -200,15 +200,15 @@ bool checkForNeedingConfigure( KDevelop::IProject* project ) { const QString currentRuntime = ICore::self()->runtimeController()->currentRuntime()->name(); - const KDevelop::Path builddir = currentBuildDir(project); + const KDevelop::Path builddir = currentBuildDir(project, true); const bool isValid = (buildDirRuntime(project, -1) == currentRuntime || buildDirRuntime(project, -1).isEmpty()) && builddir.isValid(); if( !isValid ) { CMakeBuildDirChooser bd; bd.setProject( project ); - const auto builddirs = CMake::allBuildDirs(project); + const auto builddirs = CMake::allBuildDirs(project, true); bd.setAlreadyUsed( builddirs ); bd.setShowAvailableBuildDirs(!builddirs.isEmpty()); bd.setCMakeExecutable(currentCMakeExecutable(project)); @@ -293,9 +293,14 @@ return project->path().cd(CMake::projectRootRelative(project)); } -KDevelop::Path currentBuildDir( KDevelop::IProject* project, int builddir ) +KDevelop::Path currentBuildDir( KDevelop::IProject* project, bool canonical, int builddir ) { - return KDevelop::Path(readBuildDirParameter( project, Config::Specific::buildDirPathKey, QString(), builddir )); + KDevelop::Path buildDir(readBuildDirParameter( project, Config::Specific::buildDirPathKey, QString(), builddir )); + if (canonical) { + return KDevelop::Path(QFileInfo(buildDir.toLocalFile()).canonicalFilePath()); + } else { + return buildDir; + } } KDevelop::Path commandsFile(KDevelop::IProject* project) @@ -620,12 +625,18 @@ return KDevelop::ICore::self()->pluginController()->extensionForPlugin(QStringLiteral("org.kdevelop.ICMakeDocumentation")); } -QStringList allBuildDirs(KDevelop::IProject* project) +QStringList allBuildDirs(KDevelop::IProject* project, bool canonical) { QStringList result; int bdCount = buildDirCount(project); - for (int i = 0; i < bdCount; ++i) - result += buildDirGroup( project, i ).readEntry( Config::Specific::buildDirPathKey ); + for (int i = 0; i < bdCount; ++i) { + QString buildDir = buildDirGroup( project, i ).readEntry( Config::Specific::buildDirPathKey ); + if (canonical) { + result += QFileInfo(buildDir).canonicalFilePath(); + } else { + result += buildDir; + } + } return result; } Index: plugins/cmake/settings/cmakepreferences.cpp =================================================================== --- plugins/cmake/settings/cmakepreferences.cpp +++ plugins/cmake/settings/cmakepreferences.cpp @@ -336,7 +336,9 @@ if(curr < 0) return; - Path removedPath = CMake::currentBuildDir( m_project ); + // would we ever want to delete anything other than the actual directory + // (in case the user-specified path contains symlinks)?! + Path removedPath = CMake::currentBuildDir( m_project, true ); QString removed = removedPath.toLocalFile(); if(QDir(removed).exists()) {