summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-08-27 14:04:09 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-08-27 14:04:09 (GMT)
commit0d0b9b52f8a538a6327e2e9f848b943474afc682 (patch)
tree31f9f4d82a1dd818df02a7697244a1760ae499ae
parent6904b6efdc2ea35c3490ba33cb352b03ea3085f5 (diff)
parent637c56b4e0ce0205f3f28a670881aad07320ff17 (diff)
downloadCMake-0d0b9b52f8a538a6327e2e9f848b943474afc682.zip
CMake-0d0b9b52f8a538a6327e2e9f848b943474afc682.tar.gz
CMake-0d0b9b52f8a538a6327e2e9f848b943474afc682.tar.bz2
Merge topic 'cmState-ProjectName'
637c56b4 cmGlobalGenerator: Implement FillProjectMap in terms of cmState. b3f2299e cmState: Move ProjectName from cmMakefile. 6ce940ac cmMakefile: Use std::string in ProjectName API. e8c0341d cmMakefile: Out-of-line GetProjectName.
-rw-r--r--Source/cmCPluginAPI.cxx4
-rw-r--r--Source/cmGlobalGenerator.cxx11
-rw-r--r--Source/cmMakefile.cxx10
-rw-r--r--Source/cmMakefile.h9
-rw-r--r--Source/cmProjectCommand.cxx2
-rw-r--r--Source/cmState.cxx12
-rw-r--r--Source/cmState.h3
7 files changed, 34 insertions, 17 deletions
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 591a2cd..7da334e 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -115,7 +115,9 @@ void CCONV cmAddCacheDefinition(void *arg, const char* name,
const char* CCONV cmGetProjectName(void *arg)
{
cmMakefile *mf = static_cast<cmMakefile *>(arg);
- return mf->GetProjectName();
+ static std::string name;
+ name = mf->GetProjectName();
+ return name.c_str();
}
const char* CCONV cmGetHomeDirectory(void *arg)
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index be7896d..bdd5b5a 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2112,18 +2112,19 @@ void cmGlobalGenerator::FillProjectMap()
for(i = 0; i < this->LocalGenerators.size(); ++i)
{
// for each local generator add all projects
- cmLocalGenerator *lg = this->LocalGenerators[i];
+ cmState::Snapshot snp = this->LocalGenerators[i]->GetStateSnapshot();
std::string name;
do
{
- if (name != lg->GetMakefile()->GetProjectName())
+ std::string snpProjName = snp.GetProjectName();
+ if (name != snpProjName)
{
- name = lg->GetMakefile()->GetProjectName();
+ name = snpProjName;
this->ProjectMap[name].push_back(this->LocalGenerators[i]);
}
- lg = lg->GetParent();
+ snp = snp.GetBuildsystemDirectoryParent();
}
- while (lg);
+ while (snp.IsValid());
}
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 2296d5a..dbf41cc 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1525,7 +1525,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
parent->GetProperty("LINK_DIRECTORIES"));
// the initial project name
- this->ProjectName = parent->ProjectName;
+ this->SetProjectName(parent->GetProjectName());
// Copy include regular expressions.
this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression;
@@ -2044,11 +2044,15 @@ void cmMakefile::RemoveCacheDefinition(const std::string& name)
this->GetState()->RemoveCacheEntry(name);
}
-void cmMakefile::SetProjectName(const char* p)
+void cmMakefile::SetProjectName(std::string const& p)
{
- this->ProjectName = p;
+ this->StateSnapshot.SetProjectName(p);
}
+std::string cmMakefile::GetProjectName() const
+{
+ return this->StateSnapshot.GetProjectName();
+}
void cmMakefile::AddGlobalLinkInformation(const std::string& name,
cmTarget& target)
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 055170a..81bb510 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -274,15 +274,12 @@ public:
/**
* Specify the name of the project for this build.
*/
- void SetProjectName(const char*);
+ void SetProjectName(std::string const& name);
/**
* Get the name of the project for this build.
*/
- const char* GetProjectName() const
- {
- return this->ProjectName.c_str();
- }
+ std::string GetProjectName() const;
/** Get the configurations to be generated. */
std::string GetConfigurations(std::vector<std::string>& configs,
@@ -813,8 +810,6 @@ protected:
mutable std::set<cmListFileContext> CMP0054ReportedIds;
- std::string ProjectName; // project name
-
// libraries, classes, and executables
mutable cmTargets Targets;
#if defined(CMAKE_BUILD_WITH_CMAKE)
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index 46d7e01..7123125 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -20,7 +20,7 @@ bool cmProjectCommand
this->SetError("PROJECT called with incorrect number of arguments");
return false;
}
- this->Makefile->SetProjectName(args[0].c_str());
+ this->Makefile->SetProjectName(args[0]);
std::string bindir = args[0];
bindir += "_BINARY_DIR";
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index a401265..b30c10b 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -75,6 +75,8 @@ struct cmState::BuildsystemDirectoryStateType
std::vector<std::string> CompileOptions;
std::vector<cmListFileBacktrace> CompileOptionsBacktraces;
+ std::string ProjectName;
+
cmPropertyMap Properties;
std::vector<cmState::Snapshot> Children;
@@ -1322,6 +1324,16 @@ cmState::Directory cmState::Snapshot::GetDirectory() const
return Directory(this->Position->BuildSystemDirectory, *this);
}
+void cmState::Snapshot::SetProjectName(const std::string& name)
+{
+ this->Position->BuildSystemDirectory->ProjectName = name;
+}
+
+std::string cmState::Snapshot::GetProjectName() const
+{
+ return this->Position->BuildSystemDirectory->ProjectName;
+}
+
cmState::Directory::Directory(
cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter,
const cmState::Snapshot& snapshot)
diff --git a/Source/cmState.h b/Source/cmState.h
index 3099384..99e537c 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -88,6 +88,9 @@ public:
Directory GetDirectory() const;
+ void SetProjectName(std::string const& name);
+ std::string GetProjectName() const;
+
struct StrictWeakOrder
{
bool operator()(const cmState::Snapshot& lhs,