From 21b5fdf9a39f739c3566f3e77a4c5244da1b7e3a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 27 Aug 2016 13:50:29 +0200 Subject: [PATCH] Convert: Avoid START_OUTPUT enum when converting to relative paths --- Source/cmDependsFortran.cxx | 8 +++++--- Source/cmGlobalUnixMakefileGenerator3.cxx | 12 ++++++------ Source/cmGlobalVisualStudio7Generator.cxx | 4 ++-- Source/cmLocalGenerator.cxx | 7 ++++--- Source/cmLocalUnixMakefileGenerator3.cxx | 4 ++-- Source/cmLocalVisualStudio7Generator.cxx | 10 +++++----- Source/cmMakefileExecutableTargetGenerator.cxx | 14 ++++++++------ Source/cmMakefileLibraryTargetGenerator.cxx | 17 +++++++++-------- Source/cmMakefileTargetGenerator.cxx | 6 +++--- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 10 files changed, 45 insertions(+), 39 deletions(-) diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index eb4c1ecd3..eed31fa6a 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -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"; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index d90ebf087..9443b0a41 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -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::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"; diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 0dc4497d7..ed41e60fc 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -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 } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 0162781c6..d909011ea 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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] != '.'; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 611c50281..2b22f4936 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -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::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"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 70fe81955..459203a0a 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -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::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; } diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 66e1ca2a2..c1079a2f1 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -219,25 +219,27 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // may need to be cleaned. std::vector 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) { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index c31c469be..8d90089a7 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -368,23 +368,24 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // Clean files associated with this library. std::vector 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 diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 165f96ce8..215952a5e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -173,7 +173,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() for (std::vector::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"); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8ff736658..a4065cabb 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -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 ||