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 << "\n";
fcStream << " \"" fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath( << this->LocalGenerator->ConvertToRelativePath(
mod_lower, cmOutputConverter::START_OUTPUT) this->LocalGenerator->GetCurrentBinaryDirectory(),
mod_lower)
<< "\"\n"; << "\"\n";
fcStream << " \"" fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath( << this->LocalGenerator->ConvertToRelativePath(
mod_upper, cmOutputConverter::START_OUTPUT) this->LocalGenerator->GetCurrentBinaryDirectory(),
mod_upper)
<< "\"\n"; << "\"\n";
fcStream << " \"" fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath( << this->LocalGenerator->ConvertToRelativePath(
stamp, cmOutputConverter::START_OUTPUT) this->LocalGenerator->GetCurrentBinaryDirectory(), stamp)
<< "\"\n"; << "\"\n";
} }
fcStream << " )\n"; fcStream << " )\n";

View File

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

View File

@ -405,8 +405,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
if (vcprojName) { if (vcprojName) {
cmLocalGenerator* lg = target->GetLocalGenerator(); cmLocalGenerator* lg = target->GetLocalGenerator();
std::string dir = lg->GetCurrentBinaryDirectory(); std::string dir = lg->GetCurrentBinaryDirectory();
dir = root->ConvertToRelativePath(dir.c_str(), dir = root->ConvertToRelativePath(root->GetCurrentBinaryDirectory(),
cmOutputConverter::START_OUTPUT); dir.c_str());
if (dir == ".") { if (dir == ".") {
dir = ""; // msbuild cannot handle ".\" prefix 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) { for (vec_t::const_iterator i = children.begin(); i != children.end(); ++i) {
// TODO: Use add_subdirectory instead? // TODO: Use add_subdirectory instead?
std::string outP = i->GetDirectory().GetCurrentBinary(); std::string outP = i->GetDirectory().GetCurrentBinary();
outP = this->ConvertToRelativePath(outP, START_OUTPUT); outP =
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), outP);
outP = cmOutputConverter::EscapeForCMake(outP); outP = cmOutputConverter::EscapeForCMake(outP);
fout << "subdirs(" << outP << ")" << std::endl; fout << "subdirs(" << outP << ")" << std::endl;
} }
@ -2246,7 +2247,7 @@ std::string cmLocalGenerator::ConstructComment(
o != ccg.GetOutputs().end(); ++o) { o != ccg.GetOutputs().end(); ++o) {
comment += sep; comment += sep;
comment += comment +=
this->ConvertToRelativePath(*o, cmOutputConverter::START_OUTPUT); this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), *o);
sep = ", "; sep = ", ";
} }
return comment; return comment;
@ -2522,7 +2523,7 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
// Try referencing the source relative to the binary tree. // Try referencing the source relative to the binary tree.
std::string relFromBinary = std::string relFromBinary =
this->ConvertToRelativePath(fullPath, START_OUTPUT); this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), fullPath);
assert(!relFromBinary.empty()); assert(!relFromBinary.empty());
bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary.c_str()); bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary.c_str());
bool subBinary = relBinary && relFromBinary[0] != '.'; bool subBinary = relBinary && relFromBinary[0] != '.';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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