diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2003-12-22 20:16:46 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2003-12-22 20:16:46 (GMT) |
commit | d79e3ae698413b0204c4819db1fbe25486c96fbf (patch) | |
tree | a05dc78d6ff1b7b055d3d5c9b64b92984c69a853 /Source/cmLocalUnixMakefileGenerator.cxx | |
parent | a5fa6e2fe28ac1457795490ec4d002bd8d5231ef (diff) | |
download | CMake-d79e3ae698413b0204c4819db1fbe25486c96fbf.zip CMake-d79e3ae698413b0204c4819db1fbe25486c96fbf.tar.gz CMake-d79e3ae698413b0204c4819db1fbe25486c96fbf.tar.bz2 |
ENH: move relative path to parent generator class
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator.cxx')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator.cxx | 155 |
1 files changed, 47 insertions, 108 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx index c2cdbfa..e1f9eae 100644 --- a/Source/cmLocalUnixMakefileGenerator.cxx +++ b/Source/cmLocalUnixMakefileGenerator.cxx @@ -41,40 +41,6 @@ cmLocalUnixMakefileGenerator::~cmLocalUnixMakefileGenerator() void cmLocalUnixMakefileGenerator::Generate(bool fromTheTop) { - 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 += "/"; - } - - - // suppoirt override in output directories if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) { @@ -256,18 +222,18 @@ void cmLocalUnixMakefileGenerator::OutputMakefile(const char* file, for(std::vector<std::string>::const_iterator i = lfiles.begin(); i != lfiles.end(); ++i) { - fout << " " << this->ConvertToMakefilePath(i->c_str()); + fout << " " << this->ConvertToRelativeOutputPath(i->c_str()); } // Add the cache to the list std::string cacheFile = m_Makefile->GetHomeOutputDirectory(); cacheFile += "/CMakeCache.txt"; - fout << " " << this->ConvertToMakefilePath(cacheFile.c_str()); + fout << " " << this->ConvertToRelativeOutputPath(cacheFile.c_str()); fout << "\n\n\n"; this->OutputMakeVariables(fout); std::string checkCache = m_Makefile->GetHomeOutputDirectory(); checkCache += "/cmake.check_cache"; - checkCache = this->ConvertToMakefilePath(checkCache.c_str()); + checkCache = this->ConvertToRelativeOutputPath(checkCache.c_str()); // most unix makes will pass the command line flags to make down // to sub invoked makes via an environment variable. However, some // makes do not support that, so you have to pass the flags explicitly @@ -480,7 +446,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) std::string path2 = m_LibraryOutputPath; path2 += this->GetFullTargetName(l->first.c_str(), l->second); path = "... "; - path += this->ConvertToMakefilePath(path2.c_str()); + path += this->ConvertToRelativeOutputPath(path2.c_str()); this->OutputEcho(fout,path.c_str()); } } @@ -525,7 +491,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) path = m_LibraryOutputPath; path += this->GetFullTargetName(l->first.c_str(), l->second); fout << " \\\n" - << this->ConvertToMakefilePath(path.c_str()); + << this->ConvertToRelativeOutputPath(path.c_str()); } } } @@ -539,7 +505,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) { path = m_ExecutableOutputPath; path += this->GetFullTargetName(l->first.c_str(), l->second); - fout << " \\\n" << this->ConvertToMakefilePath(path.c_str()); + fout << " \\\n" << this->ConvertToRelativeOutputPath(path.c_str()); } } // list utilities last @@ -572,7 +538,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) if(outExt.size()) { fout << "\\\n" - << this->ConvertToMakefilePath((*i)->GetSourceName().c_str()) + << this->ConvertToRelativeOutputPath((*i)->GetSourceName().c_str()) << outExt.c_str() << " "; } } @@ -588,7 +554,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) std::string outExt(this->GetOutputExtension((*i)->GetSourceExtension().c_str())); if(outExt.size()) { - fout << "\\\n\"" << this->ConvertToMakefilePath((*i)->GetSourceName().c_str()) + fout << "\\\n\"" << this->ConvertToRelativeOutputPath((*i)->GetSourceName().c_str()) << outExt.c_str() << "\" "; } } @@ -620,7 +586,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) path = m_LibraryOutputPath; path += targetNameSO; fout << " \\\n" - << this->ConvertToMakefilePath(path.c_str()); + << this->ConvertToRelativeOutputPath(path.c_str()); } if(targetNameReal != targetName && targetNameReal != targetNameSO) @@ -628,7 +594,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) path = m_LibraryOutputPath; path += targetNameReal; fout << " \\\n" - << this->ConvertToMakefilePath(path.c_str()); + << this->ConvertToRelativeOutputPath(path.c_str()); } } } @@ -899,7 +865,7 @@ std::string cmLocalUnixMakefileGenerator::CreatePreBuildRules( { initNext = true; } - std::string command = this->ConvertToMakefilePath(cc.GetCommand().c_str()); + std::string command = this->ConvertToRelativeOutputPath(cc.GetCommand().c_str()); customRuleCode += command + " " + cc.GetArguments(); } return customRuleCode; @@ -924,7 +890,7 @@ std::string cmLocalUnixMakefileGenerator::CreatePreLinkRules( { initNext = true; } - std::string command = this->ConvertToMakefilePath(cc.GetCommand().c_str()); + std::string command = this->ConvertToRelativeOutputPath(cc.GetCommand().c_str()); customRuleCode += command + " " + cc.GetArguments(); } return customRuleCode; @@ -949,7 +915,7 @@ std::string cmLocalUnixMakefileGenerator::CreatePostBuildRules( { initNext = true; } - std::string command = this->ConvertToMakefilePath(cc.GetCommand().c_str()); + std::string command = this->ConvertToRelativeOutputPath(cc.GetCommand().c_str()); customRuleCode += command + " " + cc.GetArguments(); } return customRuleCode; @@ -1104,10 +1070,10 @@ void cmLocalUnixMakefileGenerator::OutputLibraryRule(std::ostream& fout, std::string targetFullPathSO = m_LibraryOutputPath + targetNameSO; std::string targetFullPathReal = m_LibraryOutputPath + targetNameReal; std::string targetFullPathBase = m_LibraryOutputPath + targetNameBase; - targetFullPath = this->ConvertToMakefilePath(targetFullPath.c_str()); - targetFullPathSO = this->ConvertToMakefilePath(targetFullPathSO.c_str()); - targetFullPathReal = this->ConvertToMakefilePath(targetFullPathReal.c_str()); - targetFullPathBase = this->ConvertToMakefilePath(targetFullPathBase.c_str()); + targetFullPath = this->ConvertToRelativeOutputPath(targetFullPath.c_str()); + targetFullPathSO = this->ConvertToRelativeOutputPath(targetFullPathSO.c_str()); + targetFullPathReal = this->ConvertToRelativeOutputPath(targetFullPathReal.c_str()); + targetFullPathBase = this->ConvertToRelativeOutputPath(targetFullPathBase.c_str()); // get the objects that are used to link this library std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; @@ -1231,7 +1197,7 @@ void cmLocalUnixMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout, if((*i)->GetSourceExtension() == "def") { linkFlags += this->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); - linkFlags += this->ConvertToMakefilePath((*i)->GetFullPath().c_str()); + linkFlags += this->ConvertToRelativeOutputPath((*i)->GetFullPath().c_str()); linkFlags += " "; } } @@ -1335,7 +1301,7 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout, } target += name; target += cmSystemTools::GetExecutableExtension(); - target = this->ConvertToMakefilePath(target.c_str()); + target = this->ConvertToRelativeOutputPath(target.c_str()); bool needsLocalTarget = false; if(target.find('/') != target.npos) { @@ -1445,7 +1411,7 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout, depend = target; target = name; target += cmSystemTools::GetExecutableExtension(); - target = this->ConvertToMakefilePath(target.c_str()); + target = this->ConvertToRelativeOutputPath(target.c_str()); commands.resize(0); this->OutputMakeRule(fout, comment.c_str(), @@ -1492,7 +1458,7 @@ void cmLocalUnixMakefileGenerator::OutputUtilityRule(std::ostream& fout, depends += " \\\n"; replaceVars = *d; m_Makefile->ExpandVariablesInString(replaceVars); - depends += this->ConvertToMakefilePath(replaceVars.c_str()); + depends += this->ConvertToRelativeOutputPath(replaceVars.c_str()); } } this->OutputMakeRule(fout, comment.c_str(), name, @@ -1750,7 +1716,7 @@ void cmLocalUnixMakefileGenerator::OutputBuildTargetInDir(std::ostream& fout, << "; $(MAKE) $(MAKESILENT) cmake.check_depends" << "; $(MAKE) $(MAKESILENT) -f cmake.check_depends" << "; $(MAKE) $(MAKESILENT) " - << this->ConvertToMakefilePath(makeTarget) << "\n\n"; + << this->ConvertToRelativeOutputPath(makeTarget) << "\n\n"; } @@ -1821,7 +1787,7 @@ void cmLocalUnixMakefileGenerator::OutputLibDepend(std::ostream& fout, libpath += name; libpath += this->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); } - fout << this->ConvertToMakefilePath(libpath.c_str()) << " "; + fout << this->ConvertToRelativeOutputPath(libpath.c_str()) << " "; } } @@ -1860,7 +1826,7 @@ void cmLocalUnixMakefileGenerator::OutputExeDepend(std::ostream& fout, exepath += name; // add the correct extension exepath += cmSystemTools::GetExecutableExtension(); - fout << this->ConvertToMakefilePath(exepath.c_str()) << " "; + fout << this->ConvertToRelativeOutputPath(exepath.c_str()) << " "; } // if it isn't in the cache, it might still be a utility target // so check for that @@ -1959,7 +1925,7 @@ void cmLocalUnixMakefileGenerator::BuildInSubDirectory(std::ostream& fout, return; } - std::string directory = this->ConvertToMakefilePath(dir); + std::string directory = this->ConvertToRelativeOutputPath(dir); if(target1) { fout << "\t@if test ! -d " << directory @@ -2106,8 +2072,8 @@ bool cmLocalUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout) { std::string s = (*source)->GetSourceName(); s += this->GetOutputExtension((*source)->GetSourceExtension().c_str()); - fout << this->ConvertToMakefilePath(s.c_str()) << " : " - << this->ConvertToMakefilePath(dep->c_str()) << "\n"; + fout << this->ConvertToRelativeOutputPath(s.c_str()) << " : " + << this->ConvertToRelativeOutputPath(dep->c_str()) << "\n"; ret = true; } fout << "\n\n"; @@ -2158,7 +2124,7 @@ void cmLocalUnixMakefileGenerator::OutputCheckDepends(std::ostream& fout) // has been done because m_FullPath on cmDependInformation // always is it called. If it is called here, network builds are // very slow because of the number of stats - std::string dependfile = this->ConvertToMakefilePath(dep->c_str()); + std::string dependfile = this->ConvertToRelativeOutputPath(dep->c_str()); // use the lower path function to create uniqe names std::string lowerpath = this->LowerCasePath(dependfile.c_str()); if(emittedLowerPath.insert(lowerpath).second) @@ -2212,7 +2178,7 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) std::string comment = c->GetComment(); std::string command = c->GetCommand(); cmSystemTools::ReplaceString(command, "/./", "/"); - command = this->ConvertToMakefilePath(command.c_str()); + command = this->ConvertToRelativeOutputPath(command.c_str()); command += " "; // now add the arguments command += c->GetArguments(); @@ -2243,7 +2209,7 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) } cmSystemTools::ReplaceString(dep, "/./", "/"); cmSystemTools::ReplaceString(dep, "/$(IntDir)/", "/"); - dep = this->ConvertToMakefilePath(dep.c_str()); + dep = this->ConvertToRelativeOutputPath(dep.c_str()); depends += " "; depends += dep; } @@ -2269,7 +2235,7 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) std::string cmLocalUnixMakefileGenerator::ConvertToOutputForExisting(const char* p) { - std::string ret = this->ConvertToMakefilePath(p); + std::string ret = this->ConvertToRelativeOutputPath(p); // if there are spaces in the path, then get the short path version // if there is one if(ret.find(' ') != std::string::npos) @@ -2278,7 +2244,7 @@ cmLocalUnixMakefileGenerator::ConvertToOutputForExisting(const char* p) { if(!cmSystemTools::GetShortPath(ret.c_str(), ret)) { - ret = this->ConvertToMakefilePath(p); + ret = this->ConvertToRelativeOutputPath(p); } } } @@ -2325,16 +2291,16 @@ void cmLocalUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout) } fout << "CMAKE_CURRENT_SOURCE = " << - this->ConvertToMakefilePath(m_Makefile->GetStartDirectory()) + this->ConvertToRelativeOutputPath(m_Makefile->GetStartDirectory()) << "\n"; fout << "CMAKE_CURRENT_BINARY = " << - this->ConvertToMakefilePath(m_Makefile->GetStartOutputDirectory()) + this->ConvertToRelativeOutputPath(m_Makefile->GetStartOutputDirectory()) << "\n"; fout << "CMAKE_SOURCE_DIR = " << - this->ConvertToMakefilePath(m_Makefile->GetHomeDirectory()) + this->ConvertToRelativeOutputPath(m_Makefile->GetHomeDirectory()) << "\n"; fout << "CMAKE_BINARY_DIR = " << - this->ConvertToMakefilePath(m_Makefile->GetHomeOutputDirectory()) + this->ConvertToRelativeOutputPath(m_Makefile->GetHomeOutputDirectory()) << "\n"; // Output Include paths fout << "INCLUDE_FLAGS = "; @@ -2427,7 +2393,7 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout) installNameReal += targetNameReal; fname = m_LibraryOutputPath; fname += targetNameReal; - fout << "\t$(INSTALL_DATA) " << this->ConvertToMakefilePath(fname.c_str()) + fout << "\t$(INSTALL_DATA) " << this->ConvertToRelativeOutputPath(fname.c_str()) << " \"$(DESTDIR)" << prefix << l->second.GetInstallPath() << "\"\n"; fout << "\t" << cmakecommand << " -E cmake_symlink_library \"" << installNameReal << "\" \"" << installNameSO << "\" \"" << installName @@ -2437,7 +2403,7 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout) case cmTarget::EXECUTABLE: fname = m_ExecutableOutputPath; fname += this->GetFullTargetName(l->first.c_str(), l->second); - fout << "\t$(INSTALL_PROGRAM) " << this->ConvertToMakefilePath(fname.c_str()) + fout << "\t$(INSTALL_PROGRAM) " << this->ConvertToRelativeOutputPath(fname.c_str()) << " \"$(DESTDIR)" << prefix << l->second.GetInstallPath() << "\"\n"; break; case cmTarget::INSTALL_FILES: @@ -2471,7 +2437,7 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout) fout << "\t$(INSTALL_DATA) "; } - fout << this->ConvertToMakefilePath(i->c_str()) + fout << this->ConvertToRelativeOutputPath(i->c_str()) << " \"$(DESTDIR)" << prefix << l->second.GetInstallPath() << "\"\n"; } } @@ -2506,7 +2472,7 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout) { fout << "\t @$(INSTALL_PROGRAM) "; } - fout << this->ConvertToMakefilePath(i->c_str()) + fout << this->ConvertToRelativeOutputPath(i->c_str()) << " \"$(DESTDIR)" << prefix << l->second.GetInstallPath() << "\"\n"; } } @@ -2546,14 +2512,14 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout) { if(!(*source)->GetPropertyAsBool("HEADER_FILE_ONLY")) { - allsources.push_back(this->ConvertToMakefilePath((*source)->GetFullPath().c_str())); + allsources.push_back(this->ConvertToRelativeOutputPath((*source)->GetFullPath().c_str())); } } } std::string checkCache = m_Makefile->GetHomeOutputDirectory(); checkCache += "/cmake.check_cache"; - checkCache = this->ConvertToMakefilePath(checkCache.c_str()); + checkCache = this->ConvertToRelativeOutputPath(checkCache.c_str()); std::vector<std::string> cmake_depends; cmake_depends.push_back(checkCache); cmake_depends.push_back("$(CMAKE_MAKEFILE_SOURCES)"); @@ -2598,7 +2564,7 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout) std::vector<std::string> check_cache_depends; std::string CMakeCache = m_Makefile->GetHomeOutputDirectory(); CMakeCache += "/CMakeCache.txt"; - CMakeCache = this->ConvertToMakefilePath(CMakeCache.c_str()); + CMakeCache = this->ConvertToRelativeOutputPath(CMakeCache.c_str()); check_cache_depends.push_back(CMakeCache); check_cache_depends.push_back("$(CMAKE_MAKEFILE_SOURCES)"); @@ -2703,7 +2669,7 @@ OutputBuildObjectFromSource(std::ostream& fout, std::string comment = "object file"; std::string objectFile = std::string(shortName) + this->GetOutputExtension(source.GetSourceExtension().c_str()); - objectFile = this->ConvertToMakefilePath(objectFile.c_str()); + objectFile = this->ConvertToRelativeOutputPath(objectFile.c_str()); cmSystemTools::FileFormat format = cmSystemTools::GetFileFormat(source.GetSourceExtension().c_str()); std::vector<std::string> rules; @@ -2713,7 +2679,7 @@ OutputBuildObjectFromSource(std::ostream& fout, flags += extraCompileFlags; } std::string sourceFile = - this->ConvertToMakefilePath(source.GetFullPath().c_str()); + this->ConvertToRelativeOutputPath(source.GetFullPath().c_str()); std::string buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); buildType = cmSystemTools::UpperCase(buildType); switch(format) @@ -2821,7 +2787,7 @@ OutputBuildObjectFromSource(std::ostream& fout, for(std::vector<std::string>::iterator i = depends.begin(); i != depends.end(); ++i) { - sourceAndDeps.push_back(this->ConvertToMakefilePath(i->c_str())); + sourceAndDeps.push_back(this->ConvertToRelativeOutputPath(i->c_str())); } } @@ -3017,7 +2983,7 @@ void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout, replace = target; m_Makefile->ExpandVariablesInString(replace); - std::string tgt = this->ConvertToMakefilePath(replace.c_str()); + std::string tgt = this->ConvertToRelativeOutputPath(replace.c_str()); if(depends.empty()) { fout << tgt.c_str() << ":\n"; @@ -3217,30 +3183,3 @@ void cmLocalUnixMakefileGenerator::GetLibraryNames(const char* n, baseName = this->GetBaseTargetName(n, t); } -std::string cmLocalUnixMakefileGenerator::ConvertToMakefilePath(const char* p) -{ - 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; -} |