summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2003-12-22 20:16:46 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2003-12-22 20:16:46 (GMT)
commitd79e3ae698413b0204c4819db1fbe25486c96fbf (patch)
treea05dc78d6ff1b7b055d3d5c9b64b92984c69a853 /Source/cmLocalGenerator.cxx
parenta5fa6e2fe28ac1457795490ec4d002bd8d5231ef (diff)
downloadCMake-d79e3ae698413b0204c4819db1fbe25486c96fbf.zip
CMake-d79e3ae698413b0204c4819db1fbe25486c96fbf.tar.gz
CMake-d79e3ae698413b0204c4819db1fbe25486c96fbf.tar.bz2
ENH: move relative path to parent generator class
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx66
1 files changed, 66 insertions, 0 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 6389300..2c7f21d 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -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;
+}