Skip to content
Snippets Groups Projects
Commit d79e3ae6 authored by Bill Hoffman's avatar Bill Hoffman
Browse files

ENH: move relative path to parent generator class

parent a5fa6e2f
No related branches found
No related tags found
No related merge requests found
......@@ -54,9 +54,75 @@ void cmLocalGenerator::SetGlobalGenerator(cmGlobalGenerator *gg)
gg->GetCMakeInstance()->GetHomeDirectory());
m_Makefile->SetHomeOutputDirectory(
gg->GetCMakeInstance()->GetHomeOutputDirectory());
}
void cmLocalGenerator::ConfigureFinalPass()
{
m_Makefile->ConfigureFinalPass();
}
std::string cmLocalGenerator::ConvertToRelativeOutputPath(const char* p)
{
// The first time this is called, initialize all
// the path ivars that are used. This can not
// be moved to the constructor because all the paths are not set yet.
if(m_CurrentOutputDirectory.size() == 0)
{
m_CurrentOutputDirectory = m_Makefile->GetCurrentOutputDirectory();
m_HomeOutputDirectory = m_Makefile->GetHomeOutputDirectory();
m_HomeDirectory = m_Makefile->GetHomeDirectory();
#if defined(_WIN32) || defined(__APPLE__)
m_CurrentOutputDirectory = cmSystemTools::LowerCase(m_CurrentOutputDirectory);
m_HomeOutputDirectory = cmSystemTools::LowerCase(m_HomeOutputDirectory);
m_HomeDirectory = cmSystemTools::LowerCase(m_HomeDirectory);
#endif
if(m_RelativePathToSourceDir.size() == 0)
{
m_RelativePathToSourceDir = cmSystemTools::RelativePath(
m_CurrentOutputDirectory.c_str(),
m_HomeDirectory.c_str());
std::string path = m_CurrentOutputDirectory;
cmSystemTools::ReplaceString(path, m_HomeOutputDirectory.c_str(), "");
unsigned i;
m_RelativePathToBinaryDir = "";
for(i =0; i < path.size(); ++i)
{
if(path[i] == '/')
{
m_RelativePathToBinaryDir += "../";
}
}
}
m_HomeOutputDirectoryNoSlash = m_HomeOutputDirectory;
m_HomeOutputDirectory += "/";
m_CurrentOutputDirectory += "/";
}
// Do the work of converting to a relative path
std::string pathIn = p;
#if defined(_WIN32) || defined(__APPLE__)
pathIn = cmSystemTools::LowerCase(pathIn);
#endif
std::string ret = pathIn;
cmSystemTools::ReplaceString(ret, m_CurrentOutputDirectory.c_str(), "");
cmSystemTools::ReplaceString(ret, m_HomeDirectory.c_str(),
m_RelativePathToSourceDir.c_str());
cmSystemTools::ReplaceString(ret, m_HomeOutputDirectory.c_str(),
m_RelativePathToBinaryDir.c_str());
std::string relpath = m_RelativePathToBinaryDir;
if(relpath.size())
{
relpath.erase(relpath.size()-1, 1);
}
else
{
relpath = ".";
}
cmSystemTools::ReplaceString(ret, m_HomeOutputDirectoryNoSlash.c_str(),
relpath.c_str());
ret = cmSystemTools::ConvertToOutputPath(ret.c_str());
return ret;
}
......@@ -65,11 +65,19 @@ public:
///! Set the Global Generator, done on creation by the GlobalGenerator
void SetGlobalGenerator(cmGlobalGenerator *gg);
std::string ConvertToRelativeOutputPath(const char* p);
protected:
bool m_FromTheTop;
cmMakefile *m_Makefile;
cmGlobalGenerator *m_GlobalGenerator;
// members used for relative path function ConvertToMakefilePath
std::string m_RelativePathToSourceDir;
std::string m_RelativePathToBinaryDir;
std::string m_CurrentOutputDirectory;
std::string m_HomeOutputDirectory;
std::string m_HomeDirectory;
std::string m_HomeOutputDirectoryNoSlash;
};
#endif
This diff is collapsed.
......@@ -233,7 +233,6 @@ protected:
void OutputEcho(std::ostream& fout, const char *msg);
///! final processing for a path to be put in a makefile
std::string ConvertToMakefilePath(const char* p);
protected:
int m_MakefileVariableSize;
std::map<cmStdString, cmStdString> m_MakeVariableMap;
......@@ -243,12 +242,6 @@ protected:
std::string m_MakeSilentFlag;
std::string m_ExecutableOutputPath;
std::string m_LibraryOutputPath;
std::string m_RelativePathToSourceDir;
std::string m_RelativePathToBinaryDir;
std::string m_CurrentOutputDirectory;
std::string m_HomeOutputDirectory;
std::string m_HomeDirectory;
std::string m_HomeOutputDirectoryNoSlash;
bool m_WindowsShell;
bool m_PassMakeflags;
private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment