Commit 067ea9cd authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

CMake: Cleanup QString/FileName conversions

Change-Id: Ifba5afcc98823aea2f789b65b6be4de8ebf050a1
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
parent 38ec4dd6
......@@ -57,26 +57,25 @@ namespace Internal {
const char USE_NINJA_KEY[] = "CMakeProjectManager.CMakeBuildConfiguration.UseNinja";
static QString shadowBuildDirectory(const QString &projectFilePath, const Kit *k, const QString &bcName)
static FileName shadowBuildDirectory(const FileName &projectFilePath, const Kit *k, const QString &bcName)
{
if (projectFilePath.isEmpty())
return QString();
QFileInfo info(projectFilePath);
return FileName();
const QString projectName = FileName::fromString(info.absolutePath()).fileName();
const QString projectName = projectFilePath.fileName();
ProjectMacroExpander expander(projectName, k, bcName);
QDir projectDir = QDir(Project::projectDirectory(FileName::fromString(projectFilePath)).toString());
QDir projectDir = QDir(Project::projectDirectory(projectFilePath).toString());
QString buildPath = expander.expand(Core::DocumentManager::buildDirectory());
return QDir::cleanPath(projectDir.absoluteFilePath(buildPath));
return FileName::fromUserInput(projectDir.absoluteFilePath(buildPath));
}
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent) :
BuildConfiguration(parent, Core::Id(Constants::CMAKE_BC_ID)), m_useNinja(false)
{
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
setBuildDirectory(Utils::FileName::fromString(shadowBuildDirectory(project->projectFilePath().toString(),
parent->kit(),
displayName())));
setBuildDirectory(shadowBuildDirectory(project->projectFilePath(),
parent->kit(),
displayName()));
}
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent,
......@@ -170,10 +169,11 @@ QList<ProjectExplorer::BuildInfo *> CMakeBuildConfigurationFactory::availableSet
const QString &projectPath) const
{
QList<ProjectExplorer::BuildInfo *> result;
CMakeBuildInfo *info = createBuildInfo(k, ProjectExplorer::Project::projectDirectory(Utils::FileName::fromString(projectPath)).toString());
const FileName projectPathName = FileName::fromString(projectPath);
CMakeBuildInfo *info = createBuildInfo(k, ProjectExplorer::Project::projectDirectory(projectPathName).toString());
//: The name of the build configuration created by default for a cmake project.
info->displayName = tr("Default");
info->buildDirectory = FileName::fromString(shadowBuildDirectory(projectPath, k, info->displayName));
info->buildDirectory = shadowBuildDirectory(projectPathName, k, info->displayName);
result << info;
return result;
}
......@@ -188,10 +188,10 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj
CMakeBuildInfo copy(*static_cast<const CMakeBuildInfo *>(info));
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
if (copy.buildDirectory.isEmpty())
copy.buildDirectory = FileName::fromString(shadowBuildDirectory(project->projectFilePath().toString(),
parent->kit(),
copy.displayName));
if (copy.buildDirectory.isEmpty()) {
copy.buildDirectory = shadowBuildDirectory(project->projectFilePath(), parent->kit(),
copy.displayName);
}
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, &copy);
if (copw.exec() != QDialog::Accepted)
......@@ -212,7 +212,7 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj
cleanMakeStep->setAdditionalArguments(QLatin1String("clean"));
cleanMakeStep->setClean(true);
bc->setBuildDirectory(Utils::FileName::fromString(copw.buildDirectory()));
bc->setBuildDirectory(FileName::fromString(copw.buildDirectory()));
bc->setUseNinja(copw.useNinja());
// Default to all
......@@ -269,7 +269,7 @@ CMakeBuildInfo *CMakeBuildConfigurationFactory::createBuildInfo(const ProjectExp
CMakeBuildInfo *info = new CMakeBuildInfo(this);
info->typeName = tr("Build");
info->kitId = k->id();
info->environment = Utils::Environment::systemEnvironment();
info->environment = Environment::systemEnvironment();
k->addToEnvironment(info->environment);
info->useNinja = false;
info->sourceDirectory = sourceDir;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment