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.
This commit is contained in:
parent
ebf8a41984
commit
57bdc1a2f7
@ -711,6 +711,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmake cm;
|
cmake cm;
|
||||||
|
cm.SetHomeDirectory("");
|
||||||
|
cm.SetHomeOutputDirectory("");
|
||||||
cm.AddCMakePaths();
|
cm.AddCMakePaths();
|
||||||
cm.SetProgressCallback(cmCPackGeneratorProgress, this);
|
cm.SetProgressCallback(cmCPackGeneratorProgress, this);
|
||||||
cmGlobalGenerator gg;
|
cmGlobalGenerator gg;
|
||||||
|
@ -198,6 +198,8 @@ int main (int argc, char const* const* argv)
|
|||||||
"Read CPack config file: " << cpackConfigFile << std::endl);
|
"Read CPack config file: " << cpackConfigFile << std::endl);
|
||||||
|
|
||||||
cmake cminst;
|
cmake cminst;
|
||||||
|
cminst.SetHomeDirectory("");
|
||||||
|
cminst.SetHomeOutputDirectory("");
|
||||||
cminst.GetState()->RemoveUnscriptableCommands();
|
cminst.GetState()->RemoveUnscriptableCommands();
|
||||||
cmGlobalGenerator cmgg;
|
cmGlobalGenerator cmgg;
|
||||||
cmgg.SetCMakeInstance(&cminst);
|
cmgg.SetCMakeInstance(&cminst);
|
||||||
|
@ -204,6 +204,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmake cm;
|
cmake cm;
|
||||||
|
cm.SetHomeDirectory("");
|
||||||
|
cm.SetHomeOutputDirectory("");
|
||||||
std::string cmakeOutString;
|
std::string cmakeOutString;
|
||||||
cmCTestBuildAndTestCaptureRAII captureRAII(cm, cmakeOutString);
|
cmCTestBuildAndTestCaptureRAII captureRAII(cm, cmakeOutString);
|
||||||
static_cast<void>(captureRAII);
|
static_cast<void>(captureRAII);
|
||||||
|
@ -750,6 +750,8 @@ int cmCTestLaunch::Main(int argc, const char* const argv[])
|
|||||||
void cmCTestLaunch::LoadConfig()
|
void cmCTestLaunch::LoadConfig()
|
||||||
{
|
{
|
||||||
cmake cm;
|
cmake cm;
|
||||||
|
cm.SetHomeDirectory("");
|
||||||
|
cm.SetHomeOutputDirectory("");
|
||||||
cmGlobalGenerator gg;
|
cmGlobalGenerator gg;
|
||||||
gg.SetCMakeInstance(&cm);
|
gg.SetCMakeInstance(&cm);
|
||||||
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
|
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
|
||||||
|
@ -336,6 +336,8 @@ void cmCTestScriptHandler::CreateCMake()
|
|||||||
delete this->LocalGenerator;
|
delete this->LocalGenerator;
|
||||||
}
|
}
|
||||||
this->CMake = new cmake;
|
this->CMake = new cmake;
|
||||||
|
this->CMake->SetHomeDirectory("");
|
||||||
|
this->CMake->SetHomeOutputDirectory("");
|
||||||
this->CMake->AddCMakePaths();
|
this->CMake->AddCMakePaths();
|
||||||
this->GlobalGenerator = new cmGlobalGenerator;
|
this->GlobalGenerator = new cmGlobalGenerator;
|
||||||
this->GlobalGenerator->SetCMakeInstance(this->CMake);
|
this->GlobalGenerator->SetCMakeInstance(this->CMake);
|
||||||
|
@ -1571,6 +1571,8 @@ void cmCTestTestHandler::GetListOfTests()
|
|||||||
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||||
"Constructing a list of tests" << std::endl, this->Quiet);
|
"Constructing a list of tests" << std::endl, this->Quiet);
|
||||||
cmake cm;
|
cmake cm;
|
||||||
|
cm.SetHomeDirectory("");
|
||||||
|
cm.SetHomeOutputDirectory("");
|
||||||
cmGlobalGenerator gg;
|
cmGlobalGenerator gg;
|
||||||
gg.SetCMakeInstance(&cm);
|
gg.SetCMakeInstance(&cm);
|
||||||
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
|
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
|
||||||
|
@ -104,6 +104,8 @@ int main(int argc, char const* const* argv)
|
|||||||
if(doc.CheckOptions(argc, argv))
|
if(doc.CheckOptions(argc, argv))
|
||||||
{
|
{
|
||||||
cmake hcm;
|
cmake hcm;
|
||||||
|
hcm.SetHomeDirectory("");
|
||||||
|
hcm.SetHomeOutputDirectory("");
|
||||||
hcm.AddCMakePaths();
|
hcm.AddCMakePaths();
|
||||||
std::vector<cmDocumentationEntry> generators;
|
std::vector<cmDocumentationEntry> generators;
|
||||||
hcm.GetGeneratorDocumentation(generators);
|
hcm.GetGeneratorDocumentation(generators);
|
||||||
|
@ -64,6 +64,8 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
// Construct and print requested documentation.
|
// Construct and print requested documentation.
|
||||||
cmake hcm;
|
cmake hcm;
|
||||||
|
hcm.SetHomeDirectory("");
|
||||||
|
hcm.SetHomeOutputDirectory("");
|
||||||
hcm.AddCMakePaths();
|
hcm.AddCMakePaths();
|
||||||
|
|
||||||
std::vector<cmDocumentationEntry> generators;
|
std::vector<cmDocumentationEntry> generators;
|
||||||
|
@ -510,6 +510,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmake cm;
|
cmake cm;
|
||||||
|
cm.SetHomeDirectory("");
|
||||||
|
cm.SetHomeOutputDirectory("");
|
||||||
cmGlobalGenerator gg;
|
cmGlobalGenerator gg;
|
||||||
gg.SetCMakeInstance(&cm);
|
gg.SetCMakeInstance(&cm);
|
||||||
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
|
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
|
||||||
|
@ -65,6 +65,8 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
|
|||||||
const char* fallbackSettingsFileName)
|
const char* fallbackSettingsFileName)
|
||||||
{
|
{
|
||||||
cmake cm;
|
cmake cm;
|
||||||
|
cm.SetHomeDirectory("");
|
||||||
|
cm.SetHomeOutputDirectory("");
|
||||||
cmGlobalGenerator ggi;
|
cmGlobalGenerator ggi;
|
||||||
ggi.SetCMakeInstance(&cm);
|
ggi.SetCMakeInstance(&cm);
|
||||||
cmsys::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator());
|
cmsys::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator());
|
||||||
|
@ -201,18 +201,11 @@ void cmLocalGenerator::SetupPathConversions()
|
|||||||
// Setup the current output directory components for use by
|
// Setup the current output directory components for use by
|
||||||
// Convert
|
// Convert
|
||||||
std::string outdir;
|
std::string outdir;
|
||||||
outdir =
|
|
||||||
cmSystemTools::CollapseFullPath(this->GetState()->GetSourceDirectory());
|
|
||||||
cmSystemTools::SplitPath(outdir, this->HomeDirectoryComponents);
|
|
||||||
outdir = cmSystemTools::CollapseFullPath(
|
outdir = cmSystemTools::CollapseFullPath(
|
||||||
this->StateSnapshot.GetCurrentSourceDirectory());
|
this->StateSnapshot.GetCurrentSourceDirectory());
|
||||||
cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents);
|
cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents);
|
||||||
|
|
||||||
outdir = cmSystemTools::CollapseFullPath
|
|
||||||
(this->GetState()->GetBinaryDirectory());
|
|
||||||
cmSystemTools::SplitPath(outdir,
|
|
||||||
this->HomeOutputDirectoryComponents);
|
|
||||||
|
|
||||||
outdir = cmSystemTools::CollapseFullPath
|
outdir = cmSystemTools::CollapseFullPath
|
||||||
(this->StateSnapshot.GetCurrentBinaryDirectory());
|
(this->StateSnapshot.GetCurrentBinaryDirectory());
|
||||||
cmSystemTools::SplitPath(outdir,
|
cmSystemTools::SplitPath(outdir,
|
||||||
@ -2721,8 +2714,8 @@ std::string cmLocalGenerator::Convert(const std::string& source,
|
|||||||
{
|
{
|
||||||
case HOME:
|
case HOME:
|
||||||
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
||||||
result = this->ConvertToRelativePath(this->HomeDirectoryComponents,
|
result = this->ConvertToRelativePath(
|
||||||
result);
|
this->GetState()->GetSourceDirectoryComponents(), result);
|
||||||
break;
|
break;
|
||||||
case START:
|
case START:
|
||||||
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
||||||
@ -2732,8 +2725,8 @@ std::string cmLocalGenerator::Convert(const std::string& source,
|
|||||||
case HOME_OUTPUT:
|
case HOME_OUTPUT:
|
||||||
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
||||||
result =
|
result =
|
||||||
this->ConvertToRelativePath(this->HomeOutputDirectoryComponents,
|
this->ConvertToRelativePath(
|
||||||
result);
|
this->GetState()->GetBinaryDirectoryComponents(), result);
|
||||||
break;
|
break;
|
||||||
case START_OUTPUT:
|
case START_OUTPUT:
|
||||||
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
//result = cmSystemTools::CollapseFullPath(result.c_str());
|
||||||
|
@ -458,9 +458,7 @@ protected:
|
|||||||
cmMakefile *Makefile;
|
cmMakefile *Makefile;
|
||||||
cmState::Snapshot StateSnapshot;
|
cmState::Snapshot StateSnapshot;
|
||||||
cmGlobalGenerator *GlobalGenerator;
|
cmGlobalGenerator *GlobalGenerator;
|
||||||
std::vector<std::string> HomeDirectoryComponents;
|
|
||||||
std::vector<std::string> StartDirectoryComponents;
|
std::vector<std::string> StartDirectoryComponents;
|
||||||
std::vector<std::string> HomeOutputDirectoryComponents;
|
|
||||||
std::vector<std::string> StartOutputDirectoryComponents;
|
std::vector<std::string> StartOutputDirectoryComponents;
|
||||||
cmLocalGenerator* Parent;
|
cmLocalGenerator* Parent;
|
||||||
std::vector<cmLocalGenerator*> Children;
|
std::vector<cmLocalGenerator*> Children;
|
||||||
|
@ -458,6 +458,10 @@ void cmState::SetSourceDirectory(std::string const& sourceDirectory)
|
|||||||
{
|
{
|
||||||
this->SourceDirectory = sourceDirectory;
|
this->SourceDirectory = sourceDirectory;
|
||||||
cmSystemTools::ConvertToUnixSlashes(this->SourceDirectory);
|
cmSystemTools::ConvertToUnixSlashes(this->SourceDirectory);
|
||||||
|
|
||||||
|
cmSystemTools::SplitPath(
|
||||||
|
cmSystemTools::CollapseFullPath(this->SourceDirectory),
|
||||||
|
this->SourceDirectoryComponents);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmState::GetSourceDirectory() const
|
const char* cmState::GetSourceDirectory() const
|
||||||
@ -465,10 +469,19 @@ const char* cmState::GetSourceDirectory() const
|
|||||||
return this->SourceDirectory.c_str();
|
return this->SourceDirectory.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> const& cmState::GetSourceDirectoryComponents() const
|
||||||
|
{
|
||||||
|
return this->SourceDirectoryComponents;
|
||||||
|
}
|
||||||
|
|
||||||
void cmState::SetBinaryDirectory(std::string const& binaryDirectory)
|
void cmState::SetBinaryDirectory(std::string const& binaryDirectory)
|
||||||
{
|
{
|
||||||
this->BinaryDirectory = binaryDirectory;
|
this->BinaryDirectory = binaryDirectory;
|
||||||
cmSystemTools::ConvertToUnixSlashes(this->BinaryDirectory);
|
cmSystemTools::ConvertToUnixSlashes(this->BinaryDirectory);
|
||||||
|
|
||||||
|
cmSystemTools::SplitPath(
|
||||||
|
cmSystemTools::CollapseFullPath(this->BinaryDirectory),
|
||||||
|
this->BinaryDirectoryComponents);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* cmState::GetBinaryDirectory() const
|
const char* cmState::GetBinaryDirectory() const
|
||||||
@ -476,6 +489,11 @@ const char* cmState::GetBinaryDirectory() const
|
|||||||
return this->BinaryDirectory.c_str();
|
return this->BinaryDirectory.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> const& cmState::GetBinaryDirectoryComponents() const
|
||||||
|
{
|
||||||
|
return this->BinaryDirectoryComponents;
|
||||||
|
}
|
||||||
|
|
||||||
cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot)
|
cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot)
|
||||||
{
|
{
|
||||||
PositionType pos = this->ParentPositions.size();
|
PositionType pos = this->ParentPositions.size();
|
||||||
|
@ -123,6 +123,9 @@ public:
|
|||||||
const char* GetBinaryDirectory() const;
|
const char* GetBinaryDirectory() const;
|
||||||
void SetBinaryDirectory(std::string const& binaryDirectory);
|
void SetBinaryDirectory(std::string const& binaryDirectory);
|
||||||
|
|
||||||
|
std::vector<std::string> const& GetSourceDirectoryComponents() const;
|
||||||
|
std::vector<std::string> const& GetBinaryDirectoryComponents() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
|
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
|
||||||
std::vector<std::string> EnabledLanguages;
|
std::vector<std::string> EnabledLanguages;
|
||||||
@ -132,6 +135,9 @@ private:
|
|||||||
std::vector<std::string> Locations;
|
std::vector<std::string> Locations;
|
||||||
std::vector<std::string> OutputLocations;
|
std::vector<std::string> OutputLocations;
|
||||||
std::vector<PositionType> ParentPositions;
|
std::vector<PositionType> ParentPositions;
|
||||||
|
|
||||||
|
std::vector<std::string> SourceDirectoryComponents;
|
||||||
|
std::vector<std::string> BinaryDirectoryComponents;
|
||||||
std::string SourceDirectory;
|
std::string SourceDirectory;
|
||||||
std::string BinaryDirectory;
|
std::string BinaryDirectory;
|
||||||
bool IsInTryCompile;
|
bool IsInTryCompile;
|
||||||
|
@ -1925,6 +1925,8 @@ int cmake::CheckBuildSystem()
|
|||||||
// Read the rerun check file and use it to decide whether to do the
|
// Read the rerun check file and use it to decide whether to do the
|
||||||
// global generate.
|
// global generate.
|
||||||
cmake cm;
|
cmake cm;
|
||||||
|
cm.SetHomeDirectory("");
|
||||||
|
cm.SetHomeOutputDirectory("");
|
||||||
cmGlobalGenerator gg;
|
cmGlobalGenerator gg;
|
||||||
gg.SetCMakeInstance(&cm);
|
gg.SetCMakeInstance(&cm);
|
||||||
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
|
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
|
||||||
@ -2580,6 +2582,9 @@ int cmake::Build(const std::string& dir,
|
|||||||
const std::vector<std::string>& nativeOptions,
|
const std::vector<std::string>& nativeOptions,
|
||||||
bool clean)
|
bool clean)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
this->SetHomeDirectory("");
|
||||||
|
this->SetHomeOutputDirectory("");
|
||||||
if(!cmSystemTools::FileIsDirectory(dir))
|
if(!cmSystemTools::FileIsDirectory(dir))
|
||||||
{
|
{
|
||||||
std::cerr << "Error: " << dir << " is not a directory\n";
|
std::cerr << "Error: " << dir << " is not a directory\n";
|
||||||
|
@ -214,6 +214,8 @@ int do_cmake(int ac, char const* const* av)
|
|||||||
{
|
{
|
||||||
// Construct and print requested documentation.
|
// Construct and print requested documentation.
|
||||||
cmake hcm;
|
cmake hcm;
|
||||||
|
hcm.SetHomeDirectory("");
|
||||||
|
hcm.SetHomeOutputDirectory("");
|
||||||
hcm.AddCMakePaths();
|
hcm.AddCMakePaths();
|
||||||
|
|
||||||
// the command line args are processed here so that you can do
|
// 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)
|
if (sysinfo)
|
||||||
{
|
{
|
||||||
cmake cm;
|
cmake cm;
|
||||||
|
cm.SetHomeDirectory("");
|
||||||
|
cm.SetHomeOutputDirectory("");
|
||||||
int ret = cm.GetSystemInformation(args);
|
int ret = cm.GetSystemInformation(args);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
cmake cm;
|
cmake cm;
|
||||||
|
cm.SetHomeDirectory("");
|
||||||
|
cm.SetHomeOutputDirectory("");
|
||||||
cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void *)&cm);
|
cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void *)&cm);
|
||||||
cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm);
|
cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm);
|
||||||
cm.SetWorkingMode(workingMode);
|
cm.SetWorkingMode(workingMode);
|
||||||
|
@ -160,6 +160,8 @@ int main (int argc, char const* const* argv)
|
|||||||
if(doc.CheckOptions(argc, argv))
|
if(doc.CheckOptions(argc, argv))
|
||||||
{
|
{
|
||||||
cmake hcm;
|
cmake hcm;
|
||||||
|
hcm.SetHomeDirectory("");
|
||||||
|
hcm.SetHomeOutputDirectory("");
|
||||||
hcm.AddCMakePaths();
|
hcm.AddCMakePaths();
|
||||||
|
|
||||||
// Construct and print requested documentation.
|
// Construct and print requested documentation.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user