From 7acb8e90f360e3928c58c431861eccaefe56e42a Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 13 Sep 2021 14:58:18 +0200 Subject: [PATCH] CMake: create generated file paths without QDir::cleanPath Change-Id: I49913032fb95aff8357da7aa077eabd5907d53ca Reviewed-by: hjk Reviewed-by: Cristian Adam --- .../cmakeprojectmanager/cmakebuildsystem.cpp | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index eeeca9a5cc3..e0fcb4f3aec 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -323,9 +323,8 @@ bool CMakeBuildSystem::addFiles(Node *context, const FilePaths &filePaths, FileP FilePaths CMakeBuildSystem::filesGeneratedFrom(const FilePath &sourceFile) const { - QFileInfo fi = sourceFile.toFileInfo(); FilePath project = projectDirectory(); - FilePath baseDirectory = FilePath::fromString(fi.absolutePath()); + FilePath baseDirectory = sourceFile.parentDir(); while (baseDirectory.isChildOf(project)) { const FilePath cmakeListsTxt = baseDirectory.pathAppended("CMakeLists.txt"); @@ -334,22 +333,19 @@ FilePaths CMakeBuildSystem::filesGeneratedFrom(const FilePath &sourceFile) const baseDirectory = baseDirectory.parentDir(); } - QDir srcDirRoot = QDir(project.toString()); - QString relativePath = srcDirRoot.relativeFilePath(baseDirectory.toString()); - QDir buildDir = QDir(cmakeBuildConfiguration()->buildDirectory().toString()); - QString generatedFilePath = buildDir.absoluteFilePath(relativePath); + const FilePath relativePath = baseDirectory.relativePath(project); + FilePath generatedFilePath = cmakeBuildConfiguration()->buildDirectory().resolvePath( + relativePath); - if (fi.suffix() == "ui") { - generatedFilePath += "/ui_"; - generatedFilePath += fi.completeBaseName(); - generatedFilePath += ".h"; - return {FilePath::fromString(QDir::cleanPath(generatedFilePath))}; + if (sourceFile.suffix() == "ui") { + generatedFilePath = generatedFilePath + .pathAppended("ui_" + sourceFile.completeBaseName() + ".h") + .cleanPath(); + return {generatedFilePath}; } - if (fi.suffix() == "scxml") { - generatedFilePath += "/"; - generatedFilePath += QDir::cleanPath(fi.completeBaseName()); - return {FilePath::fromString(generatedFilePath + ".h"), - FilePath::fromString(generatedFilePath + ".cpp")}; + if (sourceFile.suffix() == "scxml") { + generatedFilePath = generatedFilePath.pathAppended(sourceFile.completeBaseName()); + return {generatedFilePath.stringAppended(".h"), generatedFilePath.stringAppended(".cpp")}; } // TODO: Other types will be added when adapters for their compilers become available.