summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-05-04 21:01:29 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-05-16 06:11:33 (GMT)
commit57bdc1a2f7d416c106c4bef8f3543eec74c3c391 (patch)
tree35f8d079bab6b86e79472663bd6a582fab2be7fa
parentebf8a41984f591dbd6c22735aec7f2b1c36c9e0a (diff)
downloadCMake-57bdc1a2f7d416c106c4bef8f3543eec74c3c391.zip
CMake-57bdc1a2f7d416c106c4bef8f3543eec74c3c391.tar.gz
CMake-57bdc1a2f7d416c106c4bef8f3543eec74c3c391.tar.bz2
cmState: Compute and store directory components.
There is no need to duplicate these in all cmLocalGenerators. Rename the symbols according to current conventions. Add explicit calls to Set{Source,Binary}Directory with empty strings in order to trigger the population of the components containers with the current working directory in cmLocalGenerator. Having directories set to empty is a special case in CMake, which is relied on for the `if(CMAKE_BINARY_DIR)` condition at the end of CMakeDetermineSystem.cmake.
-rw-r--r--Source/CPack/cmCPackGenerator.cxx2
-rw-r--r--Source/CPack/cpack.cxx2
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx2
-rw-r--r--Source/CTest/cmCTestLaunch.cxx2
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx2
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx2
-rw-r--r--Source/CursesDialog/ccmake.cxx2
-rw-r--r--Source/QtDialog/CMakeSetup.cxx2
-rw-r--r--Source/cmCTest.cxx2
-rw-r--r--Source/cmGraphVizWriter.cxx2
-rw-r--r--Source/cmLocalGenerator.cxx17
-rw-r--r--Source/cmLocalGenerator.h2
-rw-r--r--Source/cmState.cxx18
-rw-r--r--Source/cmState.h6
-rw-r--r--Source/cmake.cxx5
-rw-r--r--Source/cmakemain.cxx6
-rw-r--r--Source/ctest.cxx2
17 files changed, 62 insertions, 14 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index e254e9a..f8a531c 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -711,6 +711,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
}
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
cm.AddCMakePaths();
cm.SetProgressCallback(cmCPackGeneratorProgress, this);
cmGlobalGenerator gg;
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 2207873..d08b5de 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -198,6 +198,8 @@ int main (int argc, char const* const* argv)
"Read CPack config file: " << cpackConfigFile << std::endl);
cmake cminst;
+ cminst.SetHomeDirectory("");
+ cminst.SetHomeOutputDirectory("");
cminst.GetState()->RemoveUnscriptableCommands();
cmGlobalGenerator cmgg;
cmgg.SetCMakeInstance(&cminst);
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 586070b..20d303d 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -204,6 +204,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
}
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
std::string cmakeOutString;
cmCTestBuildAndTestCaptureRAII captureRAII(cm, cmakeOutString);
static_cast<void>(captureRAII);
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index de6ecde..1e67136 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -750,6 +750,8 @@ int cmCTestLaunch::Main(int argc, const char* const argv[])
void cmCTestLaunch::LoadConfig()
{
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 0a34be8..322855a 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -336,6 +336,8 @@ void cmCTestScriptHandler::CreateCMake()
delete this->LocalGenerator;
}
this->CMake = new cmake;
+ this->CMake->SetHomeDirectory("");
+ this->CMake->SetHomeOutputDirectory("");
this->CMake->AddCMakePaths();
this->GlobalGenerator = new cmGlobalGenerator;
this->GlobalGenerator->SetCMakeInstance(this->CMake);
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 95cdf3b..0b7ff33 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -1571,6 +1571,8 @@ void cmCTestTestHandler::GetListOfTests()
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Constructing a list of tests" << std::endl, this->Quiet);
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index e013f81..5236e57 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -104,6 +104,8 @@ int main(int argc, char const* const* argv)
if(doc.CheckOptions(argc, argv))
{
cmake hcm;
+ hcm.SetHomeDirectory("");
+ hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
std::vector<cmDocumentationEntry> generators;
hcm.GetGeneratorDocumentation(generators);
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 8a72a24..349269e 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -64,6 +64,8 @@ int main(int argc, char** argv)
{
// Construct and print requested documentation.
cmake hcm;
+ hcm.SetHomeDirectory("");
+ hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
std::vector<cmDocumentationEntry> generators;
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 403a459..4245352 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -510,6 +510,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
}
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index 99542a9..bffcb7c 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -65,6 +65,8 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
const char* fallbackSettingsFileName)
{
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
cmGlobalGenerator ggi;
ggi.SetCMakeInstance(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator());
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 74362ae..a26a90f 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -201,19 +201,12 @@ void cmLocalGenerator::SetupPathConversions()
// Setup the current output directory components for use by
// Convert
std::string outdir;
- outdir =
- cmSystemTools::CollapseFullPath(this->GetState()->GetSourceDirectory());
- cmSystemTools::SplitPath(outdir, this->HomeDirectoryComponents);
+
outdir = cmSystemTools::CollapseFullPath(
this->StateSnapshot.GetCurrentSourceDirectory());
cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents);
outdir = cmSystemTools::CollapseFullPath
- (this->GetState()->GetBinaryDirectory());
- cmSystemTools::SplitPath(outdir,
- this->HomeOutputDirectoryComponents);
-
- outdir = cmSystemTools::CollapseFullPath
(this->StateSnapshot.GetCurrentBinaryDirectory());
cmSystemTools::SplitPath(outdir,
this->StartOutputDirectoryComponents);
@@ -2721,8 +2714,8 @@ std::string cmLocalGenerator::Convert(const std::string& source,
{
case HOME:
//result = cmSystemTools::CollapseFullPath(result.c_str());
- result = this->ConvertToRelativePath(this->HomeDirectoryComponents,
- result);
+ result = this->ConvertToRelativePath(
+ this->GetState()->GetSourceDirectoryComponents(), result);
break;
case START:
//result = cmSystemTools::CollapseFullPath(result.c_str());
@@ -2732,8 +2725,8 @@ std::string cmLocalGenerator::Convert(const std::string& source,
case HOME_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str());
result =
- this->ConvertToRelativePath(this->HomeOutputDirectoryComponents,
- result);
+ this->ConvertToRelativePath(
+ this->GetState()->GetBinaryDirectoryComponents(), result);
break;
case START_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str());
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index fa2f712..f08c973 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -458,9 +458,7 @@ protected:
cmMakefile *Makefile;
cmState::Snapshot StateSnapshot;
cmGlobalGenerator *GlobalGenerator;
- std::vector<std::string> HomeDirectoryComponents;
std::vector<std::string> StartDirectoryComponents;
- std::vector<std::string> HomeOutputDirectoryComponents;
std::vector<std::string> StartOutputDirectoryComponents;
cmLocalGenerator* Parent;
std::vector<cmLocalGenerator*> Children;
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 82a2939..aa690dc 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -458,6 +458,10 @@ void cmState::SetSourceDirectory(std::string const& sourceDirectory)
{
this->SourceDirectory = sourceDirectory;
cmSystemTools::ConvertToUnixSlashes(this->SourceDirectory);
+
+ cmSystemTools::SplitPath(
+ cmSystemTools::CollapseFullPath(this->SourceDirectory),
+ this->SourceDirectoryComponents);
}
const char* cmState::GetSourceDirectory() const
@@ -465,10 +469,19 @@ const char* cmState::GetSourceDirectory() const
return this->SourceDirectory.c_str();
}
+std::vector<std::string> const& cmState::GetSourceDirectoryComponents() const
+{
+ return this->SourceDirectoryComponents;
+}
+
void cmState::SetBinaryDirectory(std::string const& binaryDirectory)
{
this->BinaryDirectory = binaryDirectory;
cmSystemTools::ConvertToUnixSlashes(this->BinaryDirectory);
+
+ cmSystemTools::SplitPath(
+ cmSystemTools::CollapseFullPath(this->BinaryDirectory),
+ this->BinaryDirectoryComponents);
}
const char* cmState::GetBinaryDirectory() const
@@ -476,6 +489,11 @@ const char* cmState::GetBinaryDirectory() const
return this->BinaryDirectory.c_str();
}
+std::vector<std::string> const& cmState::GetBinaryDirectoryComponents() const
+{
+ return this->BinaryDirectoryComponents;
+}
+
cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot)
{
PositionType pos = this->ParentPositions.size();
diff --git a/Source/cmState.h b/Source/cmState.h
index ed58c64..956b4f4 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -123,6 +123,9 @@ public:
const char* GetBinaryDirectory() const;
void SetBinaryDirectory(std::string const& binaryDirectory);
+ std::vector<std::string> const& GetSourceDirectoryComponents() const;
+ std::vector<std::string> const& GetBinaryDirectoryComponents() const;
+
private:
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
std::vector<std::string> EnabledLanguages;
@@ -132,6 +135,9 @@ private:
std::vector<std::string> Locations;
std::vector<std::string> OutputLocations;
std::vector<PositionType> ParentPositions;
+
+ std::vector<std::string> SourceDirectoryComponents;
+ std::vector<std::string> BinaryDirectoryComponents;
std::string SourceDirectory;
std::string BinaryDirectory;
bool IsInTryCompile;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 5c5c428..706f50f 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1925,6 +1925,8 @@ int cmake::CheckBuildSystem()
// Read the rerun check file and use it to decide whether to do the
// global generate.
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
@@ -2580,6 +2582,9 @@ int cmake::Build(const std::string& dir,
const std::vector<std::string>& nativeOptions,
bool clean)
{
+
+ this->SetHomeDirectory("");
+ this->SetHomeOutputDirectory("");
if(!cmSystemTools::FileIsDirectory(dir))
{
std::cerr << "Error: " << dir << " is not a directory\n";
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index d82087f..577dcd9 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -214,6 +214,8 @@ int do_cmake(int ac, char const* const* av)
{
// Construct and print requested documentation.
cmake hcm;
+ hcm.SetHomeDirectory("");
+ hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
// the command line args are processed here so that you can do
@@ -317,10 +319,14 @@ int do_cmake(int ac, char const* const* av)
if (sysinfo)
{
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
int ret = cm.GetSystemInformation(args);
return ret;
}
cmake cm;
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void *)&cm);
cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm);
cm.SetWorkingMode(workingMode);
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 0fc47b7..e784759 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -160,6 +160,8 @@ int main (int argc, char const* const* argv)
if(doc.CheckOptions(argc, argv))
{
cmake hcm;
+ hcm.SetHomeDirectory("");
+ hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
// Construct and print requested documentation.