Convert: Avoid START_OUTPUT enum when converting to relative paths

This commit is contained in:
Stephen Kelly 2016-08-27 13:50:29 +02:00
parent f1d845ae74
commit 21b5fdf9a3
10 changed files with 45 additions and 39 deletions

View File

@ -206,15 +206,17 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
fcStream << "\n";
fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(
mod_lower, cmOutputConverter::START_OUTPUT)
this->LocalGenerator->GetCurrentBinaryDirectory(),
mod_lower)
<< "\"\n";
fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(
mod_upper, cmOutputConverter::START_OUTPUT)
this->LocalGenerator->GetCurrentBinaryDirectory(),
mod_upper)
<< "\"\n";
fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(
stamp, cmOutputConverter::START_OUTPUT)
this->LocalGenerator->GetCurrentBinaryDirectory(), stamp)
<< "\"\n";
}
fcStream << " )\n";

View File

@ -324,13 +324,13 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
<< "# The top level Makefile was generated from the following files:\n"
<< "set(CMAKE_MAKEFILE_DEPENDS\n"
<< " \""
<< lg->ConvertToRelativePath(cache, cmOutputConverter::START_OUTPUT)
<< lg->ConvertToRelativePath(lg->GetCurrentBinaryDirectory(), cache)
<< "\"\n";
for (std::vector<std::string>::const_iterator i = lfiles.begin();
i != lfiles.end(); ++i) {
cmakefileStream << " \""
<< lg->ConvertToRelativePath(
*i, cmOutputConverter::START_OUTPUT)
lg->GetCurrentBinaryDirectory(), *i)
<< "\"\n";
}
cmakefileStream << " )\n\n";
@ -344,12 +344,12 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
cmakefileStream << "# The corresponding makefile is:\n"
<< "set(CMAKE_MAKEFILE_OUTPUTS\n"
<< " \""
<< lg->ConvertToRelativePath(makefileName,
cmOutputConverter::START_OUTPUT)
<< lg->ConvertToRelativePath(lg->GetCurrentBinaryDirectory(),
makefileName)
<< "\"\n"
<< " \""
<< lg->ConvertToRelativePath(check,
cmOutputConverter::START_OUTPUT)
<< lg->ConvertToRelativePath(lg->GetCurrentBinaryDirectory(),
check)
<< "\"\n";
cmakefileStream << " )\n\n";

View File

@ -405,8 +405,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
if (vcprojName) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::string dir = lg->GetCurrentBinaryDirectory();
dir = root->ConvertToRelativePath(dir.c_str(),
cmOutputConverter::START_OUTPUT);
dir = root->ConvertToRelativePath(root->GetCurrentBinaryDirectory(),
dir.c_str());
if (dir == ".") {
dir = ""; // msbuild cannot handle ".\" prefix
}

View File

@ -180,7 +180,8 @@ void cmLocalGenerator::GenerateTestFiles()
for (vec_t::const_iterator i = children.begin(); i != children.end(); ++i) {
// TODO: Use add_subdirectory instead?
std::string outP = i->GetDirectory().GetCurrentBinary();
outP = this->ConvertToRelativePath(outP, START_OUTPUT);
outP =
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), outP);
outP = cmOutputConverter::EscapeForCMake(outP);
fout << "subdirs(" << outP << ")" << std::endl;
}
@ -2246,7 +2247,7 @@ std::string cmLocalGenerator::ConstructComment(
o != ccg.GetOutputs().end(); ++o) {
comment += sep;
comment +=
this->ConvertToRelativePath(*o, cmOutputConverter::START_OUTPUT);
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), *o);
sep = ", ";
}
return comment;
@ -2522,7 +2523,7 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
// Try referencing the source relative to the binary tree.
std::string relFromBinary =
this->ConvertToRelativePath(fullPath, START_OUTPUT);
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), fullPath);
assert(!relFromBinary.empty());
bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary.c_str());
bool subBinary = relBinary && relFromBinary[0] != '.';

View File

@ -977,7 +977,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
bool had_slash = cmd.find('/') != cmd.npos;
if (workingDir.empty()) {
cmd =
this->ConvertToRelativePath(cmd, cmOutputConverter::START_OUTPUT);
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), cmd);
}
bool has_slash = cmd.find('/') != cmd.npos;
if (had_slash && !has_slash) {
@ -1088,7 +1088,7 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
for (std::vector<std::string>::const_iterator f = files.begin();
f != files.end(); ++f) {
std::string fc =
this->ConvertToRelativePath(*f, cmOutputConverter::START_OUTPUT);
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), *f);
fout << " " << cmOutputConverter::EscapeForCMake(fc) << "\n";
}
fout << ")\n";

View File

@ -788,8 +788,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
target->GetProperty("Fortran_MODULE_DIRECTORY");
std::string modDir;
if (target_mod_dir) {
modDir = this->ConvertToRelativePath(target_mod_dir,
cmOutputConverter::START_OUTPUT);
modDir = this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(),
target_mod_dir);
} else {
modDir = ".";
}
@ -1301,7 +1301,7 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries(
for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
if (l->IsPath) {
std::string rel = lg->ConvertToRelativePath(
l->Value.c_str(), cmOutputConverter::START_OUTPUT);
lg->GetCurrentBinaryDirectory(), l->Value.c_str());
fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " ";
} else if (!l->Target ||
l->Target->GetType() != cmState::INTERFACE_LIBRARY) {
@ -1322,7 +1322,7 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects(
for (std::vector<std::string>::const_iterator oi = objs.begin();
oi != objs.end(); ++oi) {
std::string rel =
lg->ConvertToRelativePath(oi->c_str(), cmOutputConverter::START_OUTPUT);
lg->ConvertToRelativePath(lg->GetCurrentBinaryDirectory(), oi->c_str());
fout << sep << lg->ConvertToXMLOutputPath(rel.c_str());
sep = " ";
}
@ -1346,7 +1346,7 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
// Switch to a relative path specification if it is shorter.
if (cmSystemTools::FileIsFullPath(dir.c_str())) {
std::string rel = this->ConvertToRelativePath(
dir.c_str(), cmOutputConverter::START_OUTPUT);
this->GetCurrentBinaryDirectory(), dir.c_str());
if (rel.size() < dir.size()) {
dir = rel;
}

View File

@ -219,25 +219,27 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// may need to be cleaned.
std::vector<std::string> exeCleanFiles;
exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
targetFullPath, cmOutputConverter::START_OUTPUT));
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(
(targetFullPath + ".manifest").c_str(), cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(),
(targetFullPath + ".manifest").c_str()));
#endif
if (targetNameReal != targetName) {
exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
targetFullPathReal, cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal));
}
if (!targetNameImport.empty()) {
exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
targetFullPathImport, cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(),
targetFullPathImport));
std::string implib;
if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
implib)) {
exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
implib, cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(), implib));
}
}
@ -245,7 +247,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// cleaned. We do not want to delete the .pdb file just before
// linking the target.
this->CleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
targetFullPathPDB, cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathPDB));
// Add the pre-build and pre-link rules building but not when relinking.
if (!relink) {

View File

@ -368,23 +368,24 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Clean files associated with this library.
std::vector<std::string> libCleanFiles;
libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
targetFullPath, cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath));
if (targetNameReal != targetName) {
libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
targetFullPathReal, cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal));
}
if (targetNameSO != targetName && targetNameSO != targetNameReal) {
libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
targetFullPathSO, cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathSO));
}
if (!targetNameImport.empty()) {
libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
targetFullPathImport, cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(),
targetFullPathImport));
std::string implib;
if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
implib)) {
libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
implib, cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(), implib));
}
}
@ -392,15 +393,15 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// cleaned. We do not want to delete the .pdb file just before
// linking the target.
this->CleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath(
targetFullPathPDB, cmOutputConverter::START_OUTPUT));
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(
(targetFullPath + ".manifest").c_str(),
cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(),
(targetFullPath + ".manifest").c_str()));
}
#endif

View File

@ -173,7 +173,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(
*o, cmOutputConverter::START_OUTPUT));
this->LocalGenerator->GetCurrentBinaryDirectory(), *o));
}
}
}
@ -313,7 +313,7 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()(
output += cmSystemTools::GetFilenameName(input);
this->Generator->CleanFiles.push_back(
this->Generator->LocalGenerator->ConvertToRelativePath(
output, cmOutputConverter::START_OUTPUT));
this->Generator->LocalGenerator->GetCurrentBinaryDirectory(), output));
output = this->Generator->LocalGenerator->ConvertToRelativePath(
output, cmOutputConverter::HOME_OUTPUT);
@ -1184,7 +1184,7 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
this->ExternalObjects.begin();
i != this->ExternalObjects.end(); ++i) {
object = this->LocalGenerator->ConvertToRelativePath(
*i, cmOutputConverter::START_OUTPUT);
this->LocalGenerator->GetCurrentBinaryDirectory(), *i);
*this->BuildFileStream << " " << lineContinue << "\n"
<< this->Makefile->GetSafeDefinition(
"CMAKE_OBJECT_NAME");

View File

@ -2418,7 +2418,7 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
if (l->IsPath) {
std::string path = this->LocalGenerator->ConvertToRelativePath(
l->Value.c_str(), cmOutputConverter::START_OUTPUT);
this->LocalGenerator->GetCurrentBinaryDirectory(), l->Value.c_str());
this->ConvertToWindowsSlash(path);
libVec.push_back(path);
} else if (!l->Target ||