Commit 9c4d1056 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'cleanup-Convert'

20e62f74 cmLocalGenerator: Simplify ConvertToLinkReference
fd93b360 cmOutputConverter: Add a flag for IsUnix
1365e18b Convert: Inline platform-specific methods
1ed5f6b3 Makefiles: Introduce local RelativePath method
8377d9e0 Fortran: Inline conversion to relative path
00173b71 Fortran: Wrap path convert in a call with a more-suitable name
d5911ef0 Makefiles: Hardcode the relative location of the CMakeCache file
c3264f48 Convert: Extract method to determine if paths are in directory
52168f32 Convert: Remove asserts which are duplicated in delegate method
5213f893 Convert: Remove early return check
b61c268b Convert: Extract local variables for readability
e278f5a8 Convert: Extract local variables
51bc6bdd cmOutputConverter: remove unused code
8e0c1599 Xcode: Inline ConvertToRelativePath calls
parents 89b03498 20e62f74
Pipeline #29752 failed with stage
in 0 seconds
......@@ -75,8 +75,10 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
// Append the flag and value. Use ConvertToLinkReference to help
// vs6's "cl -link" pass it to the linker.
std::string flag = defFileFlag;
flag += (this->LocalGenerator->ConvertToLinkReference(
this->ModuleDefinitionFile->GetFullPath()));
flag += this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToLinkReference(
this->ModuleDefinitionFile->GetFullPath()),
cmOutputConverter::SHELL);
this->LocalGenerator->AppendFlags(flags, flag);
}
......
......@@ -198,16 +198,13 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
stamp += ".mod.stamp";
fcStream << "\n";
fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(currentBinDir,
mod_lower)
<< this->MaybeConvertToRelativePath(currentBinDir, mod_lower)
<< "\"\n";
fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(currentBinDir,
mod_upper)
<< this->MaybeConvertToRelativePath(currentBinDir, mod_upper)
<< "\"\n";
fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(currentBinDir,
stamp)
<< this->MaybeConvertToRelativePath(currentBinDir, stamp)
<< "\"\n";
}
fcStream << " )\n";
......@@ -323,17 +320,16 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
// Write the include dependencies to the output stream.
std::string binDir = this->LocalGenerator->GetBinaryDirectory();
std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj);
std::string obj_i = this->MaybeConvertToRelativePath(binDir, obj);
std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
internalDepends << obj_i << std::endl;
internalDepends << " " << src << std::endl;
for (std::set<std::string>::const_iterator i = info.Includes.begin();
i != info.Includes.end(); ++i) {
makeDepends
<< obj_m << ": "
<< cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, *i).c_str())
<< std::endl;
makeDepends << obj_m << ": "
<< cmSystemTools::ConvertToOutputPath(
this->MaybeConvertToRelativePath(binDir, *i).c_str())
<< std::endl;
internalDepends << " " << *i << std::endl;
}
makeDepends << std::endl;
......@@ -359,7 +355,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
proxy += *i;
proxy += ".mod.proxy";
proxy = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, proxy).c_str());
this->MaybeConvertToRelativePath(binDir, proxy).c_str());
// since we require some things add them to our list of requirements
makeDepends << obj_m << ".requires: " << proxy << std::endl;
......@@ -375,8 +371,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
if (!required->second.empty()) {
// This module is known. Depend on its timestamp file.
std::string stampFile = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, required->second)
.c_str());
this->MaybeConvertToRelativePath(binDir, required->second).c_str());
makeDepends << obj_m << ": " << stampFile << "\n";
} else {
// This module is not known to CMake. Try to locate it where
......@@ -384,7 +379,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
std::string module;
if (this->FindModule(*i, module)) {
module = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, module).c_str());
this->MaybeConvertToRelativePath(binDir, module).c_str());
makeDepends << obj_m << ": " << module << "\n";
}
}
......@@ -398,7 +393,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
proxy += *i;
proxy += ".mod.proxy";
proxy = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, proxy).c_str());
this->MaybeConvertToRelativePath(binDir, proxy).c_str());
makeDepends << proxy << ": " << obj_m << ".provides" << std::endl;
}
......@@ -420,14 +415,14 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
modFile += "/";
modFile += *i;
modFile = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(binDir, modFile),
this->MaybeConvertToRelativePath(binDir, modFile),
cmOutputConverter::SHELL);
std::string stampFile = stamp_dir;
stampFile += "/";
stampFile += m;
stampFile += ".mod.stamp";
stampFile = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(binDir, stampFile),
this->MaybeConvertToRelativePath(binDir, stampFile),
cmOutputConverter::SHELL);
makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " << modFile
<< " " << stampFile;
......@@ -448,7 +443,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
std::string driver = this->TargetDirectory;
driver += "/build";
driver = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, driver).c_str());
this->MaybeConvertToRelativePath(binDir, driver).c_str());
makeDepends << driver << ": " << obj_m << ".provides.build\n";
}
......@@ -708,3 +703,13 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
// content.
return cmFortranStreamsDiffer(finModFile, finStampFile);
}
std::string cmDependsFortran::MaybeConvertToRelativePath(
std::string const& base, std::string const& path)
{
if (!cmOutputConverter::ContainedInDirectory(
base, path, this->LocalGenerator->GetStateSnapshot().GetDirectory())) {
return path;
}
return cmOutputConverter::ForceToRelativePath(base, path);
}
......@@ -78,6 +78,9 @@ protected:
private:
cmDependsFortran(cmDependsFortran const&); // Purposely not implemented.
void operator=(cmDependsFortran const&); // Purposely not implemented.
std::string MaybeConvertToRelativePath(std::string const& base,
std::string const& path);
};
#endif
......@@ -306,16 +306,12 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
// reset lg to the first makefile
lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[0]);
// Build the path to the cache file.
std::string cache = this->GetCMakeInstance()->GetHomeOutputDirectory();
cache += "/CMakeCache.txt";
std::string currentBinDir = lg->GetCurrentBinaryDirectory();
// Save the list to the cmake file.
cmakefileStream
<< "# The top level Makefile was generated from the following files:\n"
<< "set(CMAKE_MAKEFILE_DEPENDS\n"
<< " \"" << lg->ConvertToRelativePath(currentBinDir, cache) << "\"\n";
<< " \"CMakeCache.txt\"\n";
for (std::vector<std::string>::const_iterator i = lfiles.begin();
i != lfiles.end(); ++i) {
cmakefileStream << " \"" << lg->ConvertToRelativePath(currentBinDir, *i)
......
......@@ -3325,14 +3325,14 @@ std::string cmGlobalXCodeGenerator::RelativeToSource(const char* p)
{
// We force conversion because Xcode breakpoints do not work unless
// they are in a file named relative to the source tree.
return this->CurrentLocalGenerator->ConvertToRelativePath(
this->ProjectSourceDirectoryComponents, p, true);
return cmOutputConverter::ForceToRelativePath(
cmSystemTools::JoinPath(this->ProjectSourceDirectoryComponents), p);
}
std::string cmGlobalXCodeGenerator::RelativeToBinary(const char* p)
{
return this->CurrentLocalGenerator->ConvertToRelativePath(
this->ProjectOutputDirectoryComponents, p);
cmSystemTools::JoinPath(this->ProjectOutputDirectoryComponents), p);
}
std::string cmGlobalXCodeGenerator::XCodeEscapePath(const std::string& p)
......
......@@ -1382,8 +1382,7 @@ std::string cmLocalGenerator::GetTargetFortranFlags(
return std::string();
}
std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
OutputFormat format)
std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
// Work-ardound command line parsing limitations in MSVC 6.0
......@@ -1400,17 +1399,14 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
// Append the rest of the path with no space.
sp += lib.substr(pos);
// Convert to an output path.
return this->ConvertToOutputFormat(sp.c_str(), format);
return sp;
}
}
}
#endif
// Normal behavior.
return this->ConvertToOutputFormat(
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), lib),
format);
return this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), lib);
}
/**
......@@ -1481,7 +1477,8 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
continue;
}
if (li->IsPath) {
linkLibs += this->ConvertToLinkReference(li->Value, shellFormat);
linkLibs += this->ConvertToOutputFormat(
this->ConvertToLinkReference(li->Value), shellFormat);
} else {
linkLibs += li->Value;
}
......
......@@ -370,9 +370,7 @@ protected:
std::string& CreateSafeUniqueObjectFileName(const std::string& sin,
std::string const& dir_max);
virtual std::string ConvertToLinkReference(
std::string const& lib,
cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL);
virtual std::string ConvertToLinkReference(std::string const& lib);
/** Check whether the native build system supports the given
definition. Issues a warning. */
......
......@@ -121,10 +121,9 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator()
// Virtual protected methods.
std::string cmLocalNinjaGenerator::ConvertToLinkReference(
std::string const& lib, cmOutputConverter::OutputFormat format)
std::string const& lib)
{
std::string path = this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(lib);
return this->ConvertToOutputFormat(path, format);
return this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(lib);
}
std::string cmLocalNinjaGenerator::ConvertToIncludeReference(
......
......@@ -76,9 +76,7 @@ public:
void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
cmNinjaDeps& ninjaDeps);
std::string ConvertToLinkReference(std::string const& lib,
cmOutputConverter::OutputFormat format =
cmOutputConverter::SHELL) CM_OVERRIDE;
std::string ConvertToLinkReference(std::string const& lib) CM_OVERRIDE;
void ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping,
......
......@@ -141,7 +141,7 @@ void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath()
{
// Compute the path to use when referencing the current output
// directory from the top output directory.
this->HomeRelativeOutputPath = this->ConvertToRelativePath(
this->HomeRelativeOutputPath = this->MaybeConvertToRelativePath(
this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory());
if (this->HomeRelativeOutputPath == ".") {
this->HomeRelativeOutputPath = "";
......@@ -548,7 +548,8 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
// Construct the left hand side of the rule.
std::string tgt = cmSystemTools::ConvertToOutputPath(
this->ConvertToRelativePath(this->GetBinaryDirectory(), target).c_str());
this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), target)
.c_str());
const char* space = "";
if (tgt.size() == 1) {
......@@ -577,7 +578,7 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
dep != depends.end(); ++dep) {
replace = *dep;
replace = cmSystemTools::ConvertToOutputPath(
this->ConvertToRelativePath(binDir, replace).c_str());
this->MaybeConvertToRelativePath(binDir, replace).c_str());
os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n";
}
}
......@@ -969,7 +970,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
// working directory will be the start-output directory.
bool had_slash = cmd.find('/') != cmd.npos;
if (workingDir.empty()) {
cmd = this->ConvertToRelativePath(currentBinDir, cmd);
cmd = this->MaybeConvertToRelativePath(currentBinDir, cmd);
}
bool has_slash = cmd.find('/') != cmd.npos;
if (had_slash && !has_slash) {
......@@ -994,8 +995,8 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
if (!outputs.empty()) {
if (workingDir.empty()) {
output = this->ConvertToOutputFormat(
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(),
outputs[0]),
this->MaybeConvertToRelativePath(
this->GetCurrentBinaryDirectory(), outputs[0]),
cmOutputConverter::SHELL);
} else {
......@@ -1082,14 +1083,15 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
fout << "file(REMOVE_RECURSE\n";
for (std::vector<std::string>::const_iterator f = files.begin();
f != files.end(); ++f) {
std::string fc = this->ConvertToRelativePath(currentBinDir, *f);
std::string fc = this->MaybeConvertToRelativePath(currentBinDir, *f);
fout << " " << cmOutputConverter::EscapeForCMake(fc) << "\n";
}
fout << ")\n";
}
std::string remove = "$(CMAKE_COMMAND) -P ";
remove += this->ConvertToOutputFormat(
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), cleanfile),
this->MaybeConvertToRelativePath(this->GetCurrentBinaryDirectory(),
cleanfile),
cmOutputConverter::SHELL);
commands.push_back(remove);
......@@ -1858,7 +1860,8 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
}
for (std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i) {
cmakefileStream << " \"" << this->ConvertToRelativePath(binaryDir, *i)
cmakefileStream << " \""
<< this->MaybeConvertToRelativePath(binaryDir, *i)
<< "\"\n";
}
cmakefileStream << " )\n";
......@@ -1923,7 +1926,7 @@ std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall(
if (!tgt.empty()) {
// The make target is always relative to the top of the build tree.
std::string tgt2 =
this->ConvertToRelativePath(this->GetBinaryDirectory(), tgt);
this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), tgt);
// The target may have been written with windows paths.
cmSystemTools::ConvertToOutputSlashes(tgt2);
......@@ -2095,3 +2098,13 @@ void cmLocalUnixMakefileGenerator3::CreateCDCommand(
std::bind1st(std::plus<std::string>(), prefix));
}
}
std::string cmLocalUnixMakefileGenerator3::MaybeConvertToRelativePath(
std::string const& base, std::string const& path)
{
if (!cmOutputConverter::ContainedInDirectory(
base, path, this->GetStateSnapshot().GetDirectory())) {
return path;
}
return cmOutputConverter::ForceToRelativePath(base, path);
}
......@@ -184,6 +184,9 @@ public:
// Eclipse generator.
void GetIndividualFileTargets(std::vector<std::string>& targets);
std::string MaybeConvertToRelativePath(std::string const& base,
std::string const& path);
protected:
void WriteLocalMakefile();
......
......@@ -130,16 +130,16 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
targetFullPathPDB, cmOutputConverter::SHELL);
// Convert to the output path to use in constructing commands.
std::string targetOutPath = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath),
cmOutputConverter::SHELL);
std::string targetOutPathReal = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal),
cmOutputConverter::SHELL);
std::string targetOutPathImport =
this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(),
targetFullPathImport),
cmOutputConverter::SHELL);
......@@ -220,27 +220,27 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Construct a list of files associated with this executable that
// may need to be cleaned.
std::vector<std::string> exeCleanFiles;
exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath));
#ifdef _WIN32
// There may be a manifest file for this target. Add it to the
// clean set just in case.
exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(),
(targetFullPath + ".manifest").c_str()));
#endif
if (targetNameReal != targetName) {
exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal));
}
if (!targetNameImport.empty()) {
exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(),
targetFullPathImport));
std::string implib;
if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
implib)) {
exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), implib));
}
}
......@@ -248,7 +248,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// List the PDB for cleaning only when the whole target is
// cleaned. We do not want to delete the .pdb file just before
// linking the target.
this->CleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
this->CleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathPDB));
// Add the pre-build and pre-link rules building but not when relinking.
......@@ -323,7 +323,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
objectDir = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), objectDir),
cmOutputConverter::SHELL);
vars.ObjectDir = objectDir.c_str();
......@@ -331,7 +331,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
? cmOutputConverter::WATCOMQUOTE
: cmOutputConverter::SHELL;
std::string target = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal),
output);
vars.Target = target.c_str();
......
......@@ -305,20 +305,20 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
targetFullPathPDB, cmOutputConverter::SHELL);
std::string targetOutPath = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath),
cmOutputConverter::SHELL);
std::string targetOutPathSO = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathSO),
cmOutputConverter::SHELL);
std::string targetOutPathReal = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal),
cmOutputConverter::SHELL);
std::string targetOutPathImport =
this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(),
targetFullPathImport),
cmOutputConverter::SHELL);
......@@ -366,24 +366,24 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Clean files associated with this library.
std::vector<std::string> libCleanFiles;
libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath));
if (targetNameReal != targetName) {
libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal));
}
if (targetNameSO != targetName && targetNameSO != targetNameReal) {
libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathSO));
}
if (!targetNameImport.empty()) {
libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(),
targetFullPathImport));
std::string implib;
if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
implib)) {
libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), implib));
}
}
......@@ -391,14 +391,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// List the PDB for cleaning only when the whole target is
// cleaned. We do not want to delete the .pdb file just before
// linking the target.
this->CleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
this->CleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathPDB));
#ifdef _WIN32
// There may be a manifest file for this target. Add it to the
// clean set just in case.
if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY) {
libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(),
(targetFullPath + ".manifest").c_str()));
}
......@@ -537,7 +537,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
objectDir = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), objectDir),
cmOutputConverter::SHELL);
......@@ -546,7 +546,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
? cmOutputConverter::WATCOMQUOTE
: cmOutputConverter::SHELL;
std::string target = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal),
output);
vars.Target = target.c_str();
......
......@@ -166,7 +166,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
for (std::vector<std::string>::const_iterator o = outputs.begin();
o != outputs.end(); ++o) {
this->CleanFiles.push_back(
this->LocalGenerator->ConvertToRelativePath(currentBinDir, *o));
this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, *o));
}
}
}
......@@ -209,8 +209,8 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
<< this->GlobalGenerator->IncludeDirective << " " << root
<< cmSystemTools::ConvertToOutputPath(
this->LocalGenerator
->ConvertToRelativePath(this->LocalGenerator->GetBinaryDirectory(),
dependFileNameFull)
->MaybeConvertToRelativePath(
this->LocalGenerator->GetBinaryDirectory(), dependFileNameFull)
.c_str())
<< "\n\n";
......@@ -221,7 +221,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
<< this->GlobalGenerator->IncludeDirective << " " << root
<< cmSystemTools::ConvertToOutputPath(
this->LocalGenerator
->ConvertToRelativePath(
->MaybeConvertToRelativePath(
this->LocalGenerator->GetBinaryDirectory(),
this->ProgressFileNameFull)
.c_str())
......@@ -256,8 +256,9 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
<< this->GlobalGenerator->IncludeDirective << " " << root
<< cmSystemTools::ConvertToOutputPath(
this->LocalGenerator
->ConvertToRelativePath(this->LocalGenerator->GetBinaryDirectory(),
this->FlagFileNameFull)
->MaybeConvertToRelativePath(
this->LocalGenerator->GetBinaryDirectory(),
this->FlagFileNameFull)
.c_str())
<< "\n\n";
}
......@@ -314,9 +315,9 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()(
output += "/";
output += cmSystemTools::GetFilenameName(input);
this->Generator->CleanFiles.push_back(
this->Generator->LocalGenerator->ConvertToRelativePath(
this->Generator->LocalGenerator->MaybeConvertToRelativePath(
this->Generator->LocalGenerator->GetCurrentBinaryDirectory(), output));
output = this->Generator->LocalGenerator->ConvertToRelativePath(
output = this->Generator->LocalGenerator->MaybeConvertToRelativePath(
this->Generator->LocalGenerator->GetBinaryDirectory(), output);
// Create a rule to copy the content into the bundle.
......@@ -518,13 +519,13 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
}
targetOutPathReal = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal),
cmOutputConverter::SHELL);
targetOutPathPDB = this->LocalGenerator->ConvertToOutputFormat(
targetFullPathPDB, cmOutputConverter::SHELL);
targetOutPathCompilePDB = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(),
targetFullPathCompilePDB),
cmOutputConverter::SHELL);
......@@ -550,13 +551,13 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
vars.Object = shellObj.c_str();
std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
objectDir = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), objectDir),
cmOutputConverter::SHELL);
vars.ObjectDir = objectDir.c_str();
std::string objectFileDir = cmSystemTools::GetFilenamePath(obj);
objectFileDir = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), objectFileDir),
cmOutputConverter::SHELL);
vars.ObjectFileDir = objectFileDir.c_str();
......@@ -904,7 +905,7 @@ bool cmMakefileTargetGenerator::WriteMakeRule(
// Touch the extra output so "make" knows that it was updated,
// but only if the output was acually created.
std::string const out = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(binDir, *o),
this->LocalGenerator->MaybeConvertToRelativePath(binDir, *o),
cmOutputConverter::SHELL);
std::vector<std::string> output_commands;
......@@ -1200,7 +1201,8 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
for (std::vector<std::string>::const_iterator i =
this->ExternalObjects.begin();
i != this->ExternalObjects.end(); ++i) {
object = this->LocalGenerator->ConvertToRelativePath(currentBinDir, *i);
object =
this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, *i);
*this->BuildFileStream << " " << lineContinue << "\n"
<< this->Makefile->GetSafeDefinition(
"CMAKE_OBJECT_NAME");
......@@ -1234,7 +1236,7 @@ public:
{
// Construct the name of the next object.
this->NextObject = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), obj),
cmOutputConverter::RESPONSE);
......@@ -1289,7 +1291,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(
this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget);
std::string buildTargetRuleName = dir;
buildTargetRuleName += relink ? "/preinstall" : "/build";
buildTargetRuleName = this->LocalGenerator->ConvertToRelativePath(
buildTargetRuleName = this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetBinaryDirectory(), buildTargetRuleName);
// Build the list of target outputs to drive.
......@@ -1479,7 +1481,7 @@ void cmMakefileTargetGenerator::CreateLinkScript(
// Create the makefile command to invoke the link script.
std::string link_command = "$(CMAKE_COMMAND) -E cmake_link_script ";
link_command += this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), linkScriptName),
cmOutputConverter::SHELL);
link_command += " --verbose=$(VERBOSE)";
......@@ -1716,14 +1718,14 @@ void cmMakefileTargetGenerator::GenDefFile(
cmd, cmOutputConverter::SHELL);
cmd += " -E __create_def ";
cmd += this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), name_of_def_file),
cmOutputConverter::SHELL);
cmd += " ";
std::string objlist_file = name_of_def_file;
objlist_file += ".objs";
cmd += this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), objlist_file),
cmOutputConverter::SHELL);
real_link_commands.insert(real_link_commands.begin(), cmd);
......@@ -1744,7 +1746,7 @@ void cmMakefileTargetGenerator::GenDefFile(
linkFlags += " ";
linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
linkFlags += this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), name_of_def_file),
cmOutputConverter::SHELL);
linkFlags += " ";
......
......@@ -46,7 +46,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
<< this->GlobalGenerator->IncludeDirective << " " << root
<< cmSystemTools::ConvertToOutputPath(
this->LocalGenerator
->ConvertToRelativePath(
->MaybeConvertToRelativePath(
this->LocalGenerator->GetBinaryDirectory(),
this->ProgressFileNameFull)
.c_str())
......
......@@ -76,44 +76,35 @@ static bool cmOutputConverterNotAbove(const char* a, const char* b)
cmSystemTools::IsSubDirectory(a, b));
}
std::string cmOutputConverter::ConvertToRelativePath(