CMake: Make shadowBuildDirectory helper available

Make shadowBuildDirectory(...) a static method of CMakeBuildConfiguration.
That way it can be used by a future projectimporter.

Change-Id: I1b3ffc821ac9197aa5c90e2b78891df7a81a31dd
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2016-03-01 14:12:35 +01:00
parent 68b99dac2b
commit a8853fa8b1
2 changed files with 25 additions and 16 deletions

View File

@@ -60,19 +60,6 @@ namespace Internal {
const char INITIAL_ARGUMENTS[] = "CMakeProjectManager.CMakeBuildConfiguration.InitialArgument"; // Obsolete since QtC 3.7 const char INITIAL_ARGUMENTS[] = "CMakeProjectManager.CMakeBuildConfiguration.InitialArgument"; // Obsolete since QtC 3.7
const char CONFIGURATION_KEY[] = "CMake.Configuration"; const char CONFIGURATION_KEY[] = "CMake.Configuration";
static FileName shadowBuildDirectory(const FileName &projectFilePath, const Kit *k,
const QString &bcName, BuildConfiguration::BuildType buildType)
{
if (projectFilePath.isEmpty())
return FileName();
const QString projectName = projectFilePath.parentDir().fileName();
ProjectMacroExpander expander(projectName, k, bcName, buildType);
QDir projectDir = QDir(Project::projectDirectory(projectFilePath).toString());
QString buildPath = expander.expand(Core::DocumentManager::buildDirectory());
return FileName::fromUserInput(projectDir.absoluteFilePath(buildPath));
}
CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent) : CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent) :
BuildConfiguration(parent, Core::Id(Constants::CMAKE_BC_ID)) BuildConfiguration(parent, Core::Id(Constants::CMAKE_BC_ID))
{ {
@@ -187,6 +174,21 @@ bool CMakeBuildConfiguration::persistCMakeState()
return m_buildDirManager->persistCMakeState(); return m_buildDirManager->persistCMakeState();
} }
FileName CMakeBuildConfiguration::shadowBuildDirectory(const FileName &projectFilePath,
const Kit *k,
const QString &bcName,
BuildConfiguration::BuildType buildType)
{
if (projectFilePath.isEmpty())
return FileName();
const QString projectName = projectFilePath.parentDir().fileName();
ProjectMacroExpander expander(projectName, k, bcName, buildType);
QDir projectDir = QDir(Project::projectDirectory(projectFilePath).toString());
QString buildPath = expander.expand(Core::DocumentManager::buildDirectory());
return FileName::fromUserInput(projectDir.absoluteFilePath(buildPath));
}
QList<ConfigModel::DataItem> CMakeBuildConfiguration::completeCMakeConfiguration() const QList<ConfigModel::DataItem> CMakeBuildConfiguration::completeCMakeConfiguration() const
{ {
if (m_buildDirManager->isParsing()) if (m_buildDirManager->isParsing())
@@ -363,7 +365,8 @@ QList<ProjectExplorer::BuildInfo *> CMakeBuildConfigurationFactory::availableSet
info->displayName = info->typeName; info->displayName = info->typeName;
} }
info->buildDirectory info->buildDirectory
= shadowBuildDirectory(projectPathName, k, info->displayName, info->buildType); = CMakeBuildConfiguration::shadowBuildDirectory(projectPathName, k,
info->displayName, info->buildType);
result << info; result << info;
} }
return result; return result;
@@ -380,8 +383,10 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj
CMakeProject *project = static_cast<CMakeProject *>(parent->project()); CMakeProject *project = static_cast<CMakeProject *>(parent->project());
if (copy.buildDirectory.isEmpty()) { if (copy.buildDirectory.isEmpty()) {
copy.buildDirectory = shadowBuildDirectory(project->projectFilePath(), parent->kit(), copy.buildDirectory
copy.displayName, info->buildType); = CMakeBuildConfiguration::shadowBuildDirectory(project->projectFilePath(),
parent->kit(),
copy.displayName, info->buildType);
} }
auto bc = new CMakeBuildConfiguration(parent); auto bc = new CMakeBuildConfiguration(parent);

View File

@@ -77,6 +77,10 @@ public:
void resetData(); void resetData();
bool persistCMakeState(); bool persistCMakeState();
static Utils::FileName
shadowBuildDirectory(const Utils::FileName &projectFilePath, const ProjectExplorer::Kit *k,
const QString &bcName, BuildConfiguration::BuildType buildType);
signals: signals:
void errorOccured(const QString &message); void errorOccured(const QString &message);