diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2003-12-22 21:21:27 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2003-12-22 21:21:27 (GMT) |
commit | 0bdb092a019c87825a88208d4fdaef77379e3004 (patch) | |
tree | b04edec139322b0b81bd3d83c43114edf27bdef1 /Source | |
parent | d79e3ae698413b0204c4819db1fbe25486c96fbf (diff) | |
download | CMake-0bdb092a019c87825a88208d4fdaef77379e3004.zip CMake-0bdb092a019c87825a88208d4fdaef77379e3004.tar.gz CMake-0bdb092a019c87825a88208d4fdaef77379e3004.tar.bz2 |
ENH: add relative paths to visual studio 6 and 7 project files
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalVisualStudio6Generator.cxx | 65 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 18 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 4 |
3 files changed, 49 insertions, 38 deletions
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cb4e94e..a78f7a6 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -57,7 +57,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile() for(i = includes.begin(); i != includes.end(); ++i) { m_IncludeOptions += " /I "; - std::string tmp = cmSystemTools::ConvertToOutputPath(i->c_str()); + std::string tmp = this->ConvertToRelativeOutputPath(i->c_str()); // quote if not already quoted if (tmp[0] != '"') @@ -171,10 +171,10 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule() std::string makefileIn = m_Makefile->GetStartDirectory(); makefileIn += "/"; makefileIn += "CMakeLists.txt"; - makefileIn = cmSystemTools::ConvertToOutputPath(makefileIn.c_str()); + makefileIn = this->ConvertToRelativeOutputPath(makefileIn.c_str()); std::string dsprule = "${CMAKE_COMMAND}"; m_Makefile->ExpandVariablesInString(dsprule); - dsprule = cmSystemTools::ConvertToOutputPath(dsprule.c_str()); + dsprule = this->ConvertToRelativeOutputPath(dsprule.c_str()); std::vector<std::string> argv; argv.push_back(makefileIn); makefileIn = m_Makefile->GetStartDirectory(); @@ -183,19 +183,19 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule() std::string args; args = "-H"; args += - cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeDirectory()); + this->ConvertToRelativeOutputPath(m_Makefile->GetHomeDirectory()); argv.push_back(args); args = "-S"; args += - cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartDirectory()); + this->ConvertToRelativeOutputPath(m_Makefile->GetStartDirectory()); argv.push_back(args); args = "-O"; args += - cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartOutputDirectory()); + this->ConvertToRelativeOutputPath(m_Makefile->GetStartOutputDirectory()); argv.push_back(args); args = "-B"; args += - cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeOutputDirectory()); + this->ConvertToRelativeOutputPath(m_Makefile->GetHomeOutputDirectory()); argv.push_back(args); std::string configFile = @@ -374,7 +374,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, // Tell MS-Dev what the source is. If the compiler knows how to // build it, then it will. fout << "SOURCE=" << - cmSystemTools::ConvertToOutputPath(source.c_str()) << "\n\n"; + this->ConvertToRelativeOutputPath(source.c_str()) << "\n\n"; if(!depends.empty()) { // Write out the dependencies for the rule. @@ -383,7 +383,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, d != depends.end(); ++d) { fout << "\\\n\t" << - cmSystemTools::ConvertToOutputPath(d->c_str()); + this->ConvertToRelativeOutputPath(d->c_str()); } fout << "\n"; } @@ -391,7 +391,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, { std::string totalCommandStr; totalCommandStr = - cmSystemTools::ConvertToOutputPath(command->GetCommand().c_str()); + this->ConvertToRelativeOutputPath(command->GetCommand().c_str()); totalCommandStr += " "; totalCommandStr += command->GetArguments(); totalCommandStr += "\n"; @@ -491,12 +491,12 @@ void cmLocalVisualStudio6Generator::WriteCustomRule(std::ostream& fout, libPath += dep; libPath += ".exe"; fout << "\\\n\t" << - cmSystemTools::ConvertToOutputPath(libPath.c_str()); + this->ConvertToRelativeOutputPath(libPath.c_str()); } else { fout << "\\\n\t" << - cmSystemTools::ConvertToOutputPath(d->c_str()); + this->ConvertToRelativeOutputPath(d->c_str()); } } fout << "\n"; @@ -511,7 +511,7 @@ void cmLocalVisualStudio6Generator::WriteCustomRule(std::ostream& fout, } // Write a rule for every output generated by this command. - fout << cmSystemTools::ConvertToOutputPath(output) + fout << this->ConvertToRelativeOutputPath(output) << " : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t"; fout << command << "\n\n"; fout << "# End Custom Build\n\n"; @@ -666,7 +666,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(const cmTarget &target, { customRuleCode += "\t"; } - customRuleCode += cmSystemTools::ConvertToOutputPath(cc.GetCommand().c_str()) + " " + cc.GetArguments(); + customRuleCode += this->ConvertToRelativeOutputPath(cc.GetCommand().c_str()) + " " + cc.GetArguments(); } for (std::vector<cmCustomCommand>::const_iterator cr = @@ -685,7 +685,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(const cmTarget &target, { customRuleCode += "\t"; } - customRuleCode += cmSystemTools::ConvertToOutputPath(cc.GetCommand().c_str()) + " " + cc.GetArguments(); + customRuleCode += this->ConvertToRelativeOutputPath(cc.GetCommand().c_str()) + " " + cc.GetArguments(); } // do the post build rules @@ -707,7 +707,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(const cmTarget &target, customRuleCode += "\t"; } customRuleCode += - cmSystemTools::ConvertToOutputPath(cc.GetCommand().c_str()) + + this->ConvertToRelativeOutputPath(cc.GetCommand().c_str()) + " " + cc.GetArguments(); } @@ -753,7 +753,6 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha { exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); } - if(libPath.size()) { // make sure there is a trailing slash @@ -762,9 +761,13 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha libPath += "/"; } std::string lpath = - cmSystemTools::ConvertToOutputPath(libPath.c_str()); + this->ConvertToRelativeOutputPath(libPath.c_str()); + if(lpath.size() == 0) + { + lpath = "."; + } std::string lpathIntDir = libPath + "$(INTDIR)"; - lpathIntDir = cmSystemTools::ConvertToOutputPath(lpathIntDir.c_str()); + lpathIntDir = this->ConvertToRelativeOutputPath(lpathIntDir.c_str()); if(pathEmitted.insert(lpath).second) { libOptions += " /LIBPATH:"; @@ -795,9 +798,13 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha exePath += "/"; } std::string lpath = - cmSystemTools::ConvertToOutputPath(exePath.c_str()); + this->ConvertToRelativeOutputPath(exePath.c_str()); + if(lpath.size() == 0) + { + lpath = "."; + } std::string lpathIntDir = exePath + "$(INTDIR)"; - lpathIntDir = cmSystemTools::ConvertToOutputPath(lpathIntDir.c_str()); + lpathIntDir = this->ConvertToRelativeOutputPath(lpathIntDir.c_str()); if(pathEmitted.insert(lpath).second) { @@ -831,9 +838,13 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha path += "/"; } std::string lpath = - cmSystemTools::ConvertToOutputPath(path.c_str()); + this->ConvertToRelativeOutputPath(path.c_str()); + if(lpath.size() == 0) + { + lpath = "."; + } std::string lpathIntDir = path + "$(INTDIR)"; - lpathIntDir = cmSystemTools::ConvertToOutputPath(lpathIntDir.c_str()); + lpathIntDir = this->ConvertToRelativeOutputPath(lpathIntDir.c_str()); if(pathEmitted.insert(lpath).second) { libOptions += " /LIBPATH:"; @@ -886,8 +897,8 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha lib += ".lib"; libDebug += ".lib"; } - lib = cmSystemTools::ConvertToOutputPath(lib.c_str()); - libDebug = cmSystemTools::ConvertToOutputPath(libDebug.c_str()); + lib = this->ConvertToRelativeOutputPath(lib.c_str()); + libDebug = this->ConvertToRelativeOutputPath(libDebug.c_str()); if (j->second == cmTarget::GENERAL) { @@ -1010,10 +1021,10 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha // to convert to output path for unix to win32 conversion cmSystemTools::ReplaceString(line, "LIBRARY_OUTPUT_PATH", removeQuotes( - cmSystemTools::ConvertToOutputPath(libPath.c_str())).c_str()); + this->ConvertToRelativeOutputPath(libPath.c_str())).c_str()); cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATH", removeQuotes( - cmSystemTools::ConvertToOutputPath(exePath.c_str())).c_str()); + this->ConvertToRelativeOutputPath(exePath.c_str())).c_str()); cmSystemTools::ReplaceString(line, "EXTRA_DEFINES", m_Makefile->GetDefineFlags()); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index eab8281..4b05d40 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -141,10 +141,10 @@ void cmLocalVisualStudio7Generator::AddVCProjBuildRule() std::string makefileIn = m_Makefile->GetStartDirectory(); makefileIn += "/"; makefileIn += "CMakeLists.txt"; - makefileIn = cmSystemTools::ConvertToOutputPath(makefileIn.c_str()); + makefileIn = this->ConvertToRelativeOutputPath(makefileIn.c_str()); std::string dsprule = "${CMAKE_COMMAND}"; m_Makefile->ExpandVariablesInString(dsprule); - dsprule = cmSystemTools::ConvertToOutputPath(dsprule.c_str()); + dsprule = this->ConvertToRelativeOutputPath(dsprule.c_str()); std::vector<std::string> argv; argv.push_back(makefileIn); makefileIn = m_Makefile->GetStartDirectory(); @@ -153,19 +153,19 @@ void cmLocalVisualStudio7Generator::AddVCProjBuildRule() std::string args; args = "-H"; args += - cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeDirectory()); + this->ConvertToRelativeOutputPath(m_Makefile->GetHomeDirectory()); argv.push_back(args); args = "-S"; args += - cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartDirectory()); + this->ConvertToRelativeOutputPath(m_Makefile->GetStartDirectory()); argv.push_back(args); args = "-O"; args += - cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartOutputDirectory()); + this->ConvertToRelativeOutputPath(m_Makefile->GetStartOutputDirectory()); argv.push_back(args); args = "-B"; args += - cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeOutputDirectory()); + this->ConvertToRelativeOutputPath(m_Makefile->GetHomeOutputDirectory()); argv.push_back(args); std::string configFile = @@ -856,7 +856,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, { std::string totalCommandStr; totalCommandStr = - cmSystemTools::ConvertToOutputPath(command->GetCommand().c_str()); + this->ConvertToRelativeOutputPath(command->GetCommand().c_str()); totalCommandStr += " "; totalCommandStr += command->GetArguments(); totalCommandStr += "\n"; @@ -1149,7 +1149,7 @@ std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s) std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPath(const char* path) { - std::string ret = cmSystemTools::ConvertToOutputPath(path); + std::string ret = this->ConvertToRelativeOutputPath(path); cmSystemTools::ReplaceString(ret, "&", "&"); cmSystemTools::ReplaceString(ret, "\"", """); cmSystemTools::ReplaceString(ret, "<", "<"); @@ -1159,7 +1159,7 @@ std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPath(const char* pa std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(const char* path) { - std::string ret = cmSystemTools::ConvertToOutputPath(path); + std::string ret = this->ConvertToRelativeOutputPath(path); cmSystemTools::ReplaceString(ret, "\"", ""); cmSystemTools::ReplaceString(ret, "&", "&"); cmSystemTools::ReplaceString(ret, "<", "<"); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 72a2593..5c4f307 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1107,14 +1107,14 @@ std::string cmSystemTools::RelativePath(const char* local, const char* remote) std::vector<std::string> fileSplit = cmSystemTools::SplitString(local); std::vector<std::string> relativeSplit = cmSystemTools::SplitString(remote); // count up how many mathing directory names there are from the start - int sameCount = 0; + unsigned int sameCount = 0; while(sameCount < fileSplit.size()-1 && sameCount < relativeSplit.size()-1 && fileSplit[sameCount] == relativeSplit[sameCount]) { sameCount++; } // put in sameCount number of ../ into the path - int i; + unsigned int i; for(i = sameCount; i < fileSplit.size(); ++i) { relativePath += "../"; |