Commit 160a7ad6 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'cleanup-Convert'

6429d6d9 cmOutputConverter: Remove now-obsolete Convert method
ad790617 Convert: Inline uses of START_OUTPUT
4cf707b0 Convert: Remove HOME_OUTPUT enum value
3d12ffbf Ninja: Update comment variable reference
4d69ac76 Convert: Move access to BinaryDirectory out of loops
e7c89567 Convert: Inline uses of HOME_OUTPUT
dc510919 Common: Use a string instead of enum for WorkingDirectory
76833149 Convert: Simplify switch
dc95020e Convert: Remove obsolete MAKERULE enum value
1825f876 Convert: Move access to BinaryDirectory out of loops
25c39ac2 Convert: Inline HOME_OUTPUT MAKERULE conversion
516e79ba Convert: Inline MAKERULE conversions
e13e519e Convert: Move access to BinaryDirectory out of loops
34c6e995 Convert: Avoid HOME_OUTPUT enum when converting to relative paths
839c65bc Convert: Move access to CurrentBinaryDirectory out of loops
21b5fdf9 Convert: Avoid START_OUTPUT enum when converting to relative paths
...
parents 9034a7ac 6429d6d9
......@@ -47,13 +47,6 @@ std::string const& cmCommonTargetGenerator::GetConfigName() const
return this->ConfigName;
}
std::string cmCommonTargetGenerator::Convert(
std::string const& source, cmOutputConverter::RelativeRoot relative,
cmOutputConverter::OutputFormat output)
{
return this->LocalGenerator->Convert(source, relative, output);
}
const char* cmCommonTargetGenerator::GetFeature(const std::string& feature)
{
return this->GeneratorTarget->GetFeature(feature, this->ConfigName);
......@@ -204,8 +197,9 @@ std::string cmCommonTargetGenerator::GetManifests()
std::vector<std::string> manifests;
for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
mi != manifest_srcs.end(); ++mi) {
manifests.push_back(this->Convert(
(*mi)->GetFullPath(), this->LocalGenerator->GetWorkingDirectory(),
manifests.push_back(this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(
this->LocalGenerator->GetWorkingDirectory(), (*mi)->GetFullPath()),
cmOutputConverter::SHELL));
}
......
......@@ -57,10 +57,6 @@ protected:
// The windows module definition source file (.def), if any.
cmSourceFile const* ModuleDefinitionFile;
std::string Convert(std::string const& source,
cmOutputConverter::RelativeRoot relative,
cmOutputConverter::OutputFormat output);
void AppendFortranFormatFlags(std::string& flags,
cmSourceFile const& source);
......
......@@ -239,19 +239,18 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// written by the original local generator for this directory
// convert the dependencies to paths relative to the home output
// directory. We must do the same here.
std::string obj_i = this->LocalGenerator->ConvertToRelativePath(
obj, cmOutputConverter::HOME_OUTPUT);
std::string obj_m = this->LocalGenerator->ConvertToOutputFormat(
obj_i, cmOutputConverter::MAKERULE);
std::string binDir = this->LocalGenerator->GetBinaryDirectory();
std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj);
std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
internalDepends << obj_i << std::endl;
for (std::set<std::string>::const_iterator i = dependencies.begin();
i != dependencies.end(); ++i) {
makeDepends << obj_m << ": "
<< this->LocalGenerator->Convert(
*i, cmOutputConverter::HOME_OUTPUT,
cmOutputConverter::MAKERULE)
<< std::endl;
makeDepends
<< obj_m << ": "
<< cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, *i).c_str())
<< std::endl;
internalDepends << " " << *i << std::endl;
}
makeDepends << std::endl;
......
......@@ -189,6 +189,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
cmGeneratedFileStream fcStream(fcName.c_str());
fcStream << "# Remove fortran modules provided by this target.\n";
fcStream << "FILE(REMOVE";
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
for (std::set<std::string>::const_iterator i = provides.begin();
i != provides.end(); ++i) {
std::string mod_upper = mod_dir;
......@@ -205,16 +207,16 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
stamp += ".mod.stamp";
fcStream << "\n";
fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(
mod_lower, cmOutputConverter::START_OUTPUT)
<< this->LocalGenerator->ConvertToRelativePath(currentBinDir,
mod_lower)
<< "\"\n";
fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(
mod_upper, cmOutputConverter::START_OUTPUT)
<< this->LocalGenerator->ConvertToRelativePath(currentBinDir,
mod_upper)
<< "\"\n";
fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(
stamp, cmOutputConverter::START_OUTPUT)
<< this->LocalGenerator->ConvertToRelativePath(currentBinDir,
stamp)
<< "\"\n";
}
fcStream << " )\n";
......@@ -329,19 +331,18 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
const char* src = info.Source.c_str();
// Write the include dependencies to the output stream.
std::string obj_i = this->LocalGenerator->ConvertToRelativePath(
obj, cmOutputConverter::HOME_OUTPUT);
std::string obj_m = this->LocalGenerator->ConvertToOutputFormat(
obj_i, cmOutputConverter::MAKERULE);
std::string binDir = this->LocalGenerator->GetBinaryDirectory();
std::string obj_i = this->LocalGenerator->ConvertToRelativePath(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 << ": "
<< this->LocalGenerator->Convert(
*i, cmOutputConverter::HOME_OUTPUT,
cmOutputConverter::MAKERULE)
<< std::endl;
makeDepends
<< obj_m << ": "
<< cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, *i).c_str())
<< std::endl;
internalDepends << " " << *i << std::endl;
}
makeDepends << std::endl;
......@@ -366,8 +367,8 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
proxy += "/";
proxy += *i;
proxy += ".mod.proxy";
proxy = this->LocalGenerator->Convert(
proxy, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::MAKERULE);
proxy = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, proxy).c_str());
// since we require some things add them to our list of requirements
makeDepends << obj_m << ".requires: " << proxy << std::endl;
......@@ -382,17 +383,17 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
}
if (!required->second.empty()) {
// This module is known. Depend on its timestamp file.
std::string stampFile = this->LocalGenerator->Convert(
required->second, cmOutputConverter::HOME_OUTPUT,
cmOutputConverter::MAKERULE);
std::string stampFile = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, required->second)
.c_str());
makeDepends << obj_m << ": " << stampFile << "\n";
} else {
// This module is not known to CMake. Try to locate it where
// the compiler will and depend on that.
std::string module;
if (this->FindModule(*i, module)) {
module = this->LocalGenerator->Convert(
module, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::MAKERULE);
module = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, module).c_str());
makeDepends << obj_m << ": " << module << "\n";
}
}
......@@ -405,8 +406,8 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
proxy += "/";
proxy += *i;
proxy += ".mod.proxy";
proxy = this->LocalGenerator->Convert(
proxy, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::MAKERULE);
proxy = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, proxy).c_str());
makeDepends << proxy << ": " << obj_m << ".provides" << std::endl;
}
......@@ -427,14 +428,16 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
std::string modFile = mod_dir;
modFile += "/";
modFile += *i;
modFile = this->LocalGenerator->Convert(
modFile, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::SHELL);
modFile = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(binDir, modFile),
cmOutputConverter::SHELL);
std::string stampFile = stamp_dir;
stampFile += "/";
stampFile += m;
stampFile += ".mod.stamp";
stampFile = this->LocalGenerator->Convert(
stampFile, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::SHELL);
stampFile = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(binDir, stampFile),
cmOutputConverter::SHELL);
makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " << modFile
<< " " << stampFile;
cmMakefile* mf = this->LocalGenerator->GetMakefile();
......@@ -453,8 +456,8 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
// the target finishes building.
std::string driver = this->TargetDirectory;
driver += "/build";
driver = this->LocalGenerator->Convert(
driver, cmOutputConverter::HOME_OUTPUT, cmOutputConverter::MAKERULE);
driver = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, driver).c_str());
makeDepends << driver << ": " << obj_m << ".provides.build\n";
}
......
......@@ -48,8 +48,8 @@ void cmExportBuildAndroidMKGenerator::GenerateImportTargetCode(
os << "LOCAL_MODULE := ";
os << targetName << "\n";
os << "LOCAL_SRC_FILES := ";
std::string path = target->GetLocalGenerator()->ConvertToOutputFormat(
target->GetFullPath(), cmOutputConverter::MAKERULE);
std::string path =
cmSystemTools::ConvertToOutputPath(target->GetFullPath().c_str());
os << path << "\n";
}
......
......@@ -914,7 +914,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
const std::vector<cmGeneratorTarget*> targets =
(*it)->GetGeneratorTargets();
std::string subdir = (*it)->ConvertToRelativePath(
(*it)->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
this->HomeOutputDirectory, (*it)->GetCurrentBinaryDirectory());
if (subdir == ".") {
subdir = "";
}
......
......@@ -2579,7 +2579,7 @@ void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
// Shorten the output name (in expected use case).
cmOutputConverter converter(this->GetMakefiles()[0]->GetStateSnapshot());
std::string fname = converter.ConvertToRelativePath(
outputs[0], cmOutputConverter::HOME_OUTPUT);
this->GetMakefiles()[0]->GetState()->GetBinaryDirectory(), outputs[0]);
// Associate the hash with this output.
this->RuleHashes[fname] = hash;
......
......@@ -760,8 +760,8 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path)
{
cmLocalNinjaGenerator* ng =
static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
std::string convPath =
ng->ConvertToRelativePath(path, cmOutputConverter::HOME_OUTPUT);
std::string convPath = ng->ConvertToRelativePath(
this->LocalGenerators[0]->GetState()->GetBinaryDirectory(), path);
convPath = this->NinjaOutputPath(convPath);
#ifdef _WIN32
std::replace(convPath.begin(), convPath.end(), '/', '\\');
......@@ -774,8 +774,8 @@ std::string cmGlobalNinjaGenerator::ConvertToNinjaFolderRule(
{
cmLocalNinjaGenerator* ng =
static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
std::string convPath =
ng->ConvertToRelativePath(path + "/all", cmOutputConverter::HOME);
std::string convPath = ng->ConvertToRelativePath(
this->LocalGenerators[0]->GetState()->GetSourceDirectory(), path + "/all");
convPath = this->NinjaOutputPath(convPath);
#ifdef _WIN32
std::replace(convPath.begin(), convPath.end(), '/', '\\');
......
......@@ -319,18 +319,15 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
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(cache, cmOutputConverter::START_OUTPUT)
<< "\"\n";
<< " \"" << lg->ConvertToRelativePath(currentBinDir, cache) << "\"\n";
for (std::vector<std::string>::const_iterator i = lfiles.begin();
i != lfiles.end(); ++i) {
cmakefileStream << " \""
<< lg->ConvertToRelativePath(
*i, cmOutputConverter::START_OUTPUT)
cmakefileStream << " \"" << lg->ConvertToRelativePath(currentBinDir, *i)
<< "\"\n";
}
cmakefileStream << " )\n\n";
......@@ -344,15 +341,14 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
cmakefileStream << "# The corresponding makefile is:\n"
<< "set(CMAKE_MAKEFILE_OUTPUTS\n"
<< " \""
<< lg->ConvertToRelativePath(makefileName,
cmOutputConverter::START_OUTPUT)
<< lg->ConvertToRelativePath(currentBinDir, makefileName)
<< "\"\n"
<< " \""
<< lg->ConvertToRelativePath(check,
cmOutputConverter::START_OUTPUT)
<< " \"" << lg->ConvertToRelativePath(currentBinDir, check)
<< "\"\n";
cmakefileStream << " )\n\n";
const std::string binDir = lg->GetBinaryDirectory();
// CMake must rerun if a byproduct is missing.
{
cmakefileStream << "# Byproducts of CMake generate step:\n"
......@@ -361,9 +357,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
lg->GetMakefile()->GetOutputFiles();
for (std::vector<std::string>::const_iterator k = outfiles.begin();
k != outfiles.end(); ++k) {
cmakefileStream << " \""
<< lg->ConvertToRelativePath(
*k, cmOutputConverter::HOME_OUTPUT)
cmakefileStream << " \"" << lg->ConvertToRelativePath(binDir, *k)
<< "\"\n";
}
......@@ -375,9 +369,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
tmpStr = lg->GetCurrentBinaryDirectory();
tmpStr += cmake::GetCMakeFilesDirectory();
tmpStr += "/CMakeDirectoryInformation.cmake";
cmakefileStream << " \""
<< lg->ConvertToRelativePath(
tmpStr, cmOutputConverter::HOME_OUTPUT)
cmakefileStream << " \"" << lg->ConvertToRelativePath(binDir, tmpStr)
<< "\"\n";
}
cmakefileStream << " )\n\n";
......@@ -488,9 +480,10 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2(
}
// Begin the directory-level rules section.
std::string dir = lg->GetCurrentBinaryDirectory();
dir = lg->Convert(dir, cmOutputConverter::HOME_OUTPUT,
cmOutputConverter::MAKERULE);
std::string dir = cmSystemTools::ConvertToOutputPath(
lg->ConvertToRelativePath(lg->GetBinaryDirectory(),
lg->GetCurrentBinaryDirectory())
.c_str());
lg->WriteDivider(ruleFileStream);
ruleFileStream << "# Directory level rules for directory " << dir << "\n\n";
......@@ -538,7 +531,8 @@ void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
tname += "/fast";
}
cmOutputConverter conv(mf->GetStateSnapshot());
tname = conv.ConvertToRelativePath(tname, cmOutputConverter::HOME_OUTPUT);
tname =
conv.ConvertToRelativePath(mf->GetState()->GetBinaryDirectory(), tname);
cmSystemTools::ConvertToOutputSlashes(tname);
makeCommand.push_back(tname);
if (this->Makefiles.empty()) {
......
......@@ -382,6 +382,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
{
VisualStudioFolders.clear();
std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin();
tt != projectTargets.end(); ++tt) {
cmGeneratorTarget const* target = *tt;
......@@ -405,8 +406,7 @@ 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(rootBinaryDir, dir.c_str());
if (dir == ".") {
dir = ""; // msbuild cannot handle ".\" prefix
}
......
......@@ -896,9 +896,6 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen)
{
this->CurrentLocalGenerator = gen;
this->CurrentMakefile = gen->GetMakefile();
std::string outdir = cmSystemTools::CollapseFullPath(
this->CurrentLocalGenerator->GetCurrentBinaryDirectory());
cmSystemTools::SplitPath(outdir, this->CurrentOutputDirectoryComponents);
// Select the current set of configuration types.
this->CurrentConfigurationTypes.clear();
......
......@@ -241,7 +241,6 @@ private:
std::string CurrentXCodeHackMakefile;
std::string CurrentProject;
std::set<std::string> TargetDoneSet;
std::vector<std::string> CurrentOutputDirectoryComponents;
std::vector<std::string> ProjectSourceDirectoryComponents;
std::vector<std::string> ProjectOutputDirectoryComponents;
std::map<std::string, cmXCodeObject*> GroupMap;
......
......@@ -404,8 +404,8 @@ void cmListFileBacktrace::PrintTitle(std::ostream& out) const
cmOutputConverter converter(this->Bottom);
cmListFileContext lfc = *this->Cur;
if (!this->Bottom.GetState()->GetIsInTryCompile()) {
lfc.FilePath =
converter.ConvertToRelativePath(lfc.FilePath, cmOutputConverter::HOME);
lfc.FilePath = converter.ConvertToRelativePath(
this->Bottom.GetState()->GetSourceDirectory(), lfc.FilePath);
}
out << (lfc.Line ? " at " : " in ") << lfc;
}
......@@ -430,8 +430,8 @@ void cmListFileBacktrace::PrintCallStack(std::ostream& out) const
}
cmListFileContext lfc = *i;
if (!this->Bottom.GetState()->GetIsInTryCompile()) {
lfc.FilePath =
converter.ConvertToRelativePath(lfc.FilePath, cmOutputConverter::HOME);
lfc.FilePath = converter.ConvertToRelativePath(
this->Bottom.GetState()->GetSourceDirectory(), lfc.FilePath);
}
out << " " << lfc << "\n";
}
......
......@@ -18,8 +18,9 @@
class cmGlobalGenerator;
cmLocalCommonGenerator::cmLocalCommonGenerator(
cmGlobalGenerator* gg, cmMakefile* mf, cmOutputConverter::RelativeRoot wd)
cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
cmMakefile* mf,
std::string const& wd)
: cmLocalGenerator(gg, mf)
, WorkingDirectory(wd)
{
......@@ -55,8 +56,9 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags(
// Add a module output directory flag if necessary.
std::string mod_dir = target->GetFortranModuleDirectory();
if (!mod_dir.empty()) {
mod_dir =
this->Convert(mod_dir, this->WorkingDirectory, cmOutputConverter::SHELL);
mod_dir = this->ConvertToOutputFormat(
this->ConvertToRelativePath(this->WorkingDirectory, mod_dir),
cmOutputConverter::SHELL);
} else {
mod_dir =
this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
......
......@@ -30,21 +30,18 @@ class cmLocalCommonGenerator : public cmLocalGenerator
{
public:
cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf,
cmOutputConverter::RelativeRoot wd);
std::string const& wd);
~cmLocalCommonGenerator() CM_OVERRIDE;
std::string const& GetConfigName() { return this->ConfigName; }
cmOutputConverter::RelativeRoot GetWorkingDirectory() const
{
return this->WorkingDirectory;
}
std::string GetWorkingDirectory() const { return this->WorkingDirectory; }
std::string GetTargetFortranFlags(cmGeneratorTarget const* target,
std::string const& config) CM_OVERRIDE;
protected:
cmOutputConverter::RelativeRoot WorkingDirectory;
std::string WorkingDirectory;
void SetConfigName();
std::string ConfigName;
......
......@@ -177,10 +177,11 @@ void cmLocalGenerator::GenerateTestFiles()
}
typedef std::vector<cmState::Snapshot> vec_t;
vec_t const& children = this->Makefile->GetStateSnapshot().GetChildren();
std::string parentBinDir = this->GetCurrentBinaryDirectory();
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(parentBinDir, outP);
outP = cmOutputConverter::EscapeForCMake(outP);
fout << "subdirs(" << outP << ")" << std::endl;
}
......@@ -1408,7 +1409,9 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
#endif
// Normal behavior.
return this->Convert(lib, START_OUTPUT, format);
return this->ConvertToOutputFormat(
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), lib),
format);
}
/**
......@@ -2242,11 +2245,11 @@ std::string cmLocalGenerator::ConstructComment(
std::string comment;
comment = "Generating ";
const char* sep = "";
std::string currentBinaryDir = this->GetCurrentBinaryDirectory();
for (std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
o != ccg.GetOutputs().end(); ++o) {
comment += sep;
comment +=
this->ConvertToRelativePath(*o, cmOutputConverter::START_OUTPUT);
comment += this->ConvertToRelativePath(currentBinaryDir, *o);
sep = ", ";
}
return comment;
......@@ -2514,14 +2517,15 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
const char* fullPath = source.GetFullPath().c_str();
// Try referencing the source relative to the source tree.
std::string relFromSource = this->ConvertToRelativePath(fullPath, START);
std::string relFromSource =
this->ConvertToRelativePath(this->GetCurrentSourceDirectory(), fullPath);
assert(!relFromSource.empty());
bool relSource = !cmSystemTools::FileIsFullPath(relFromSource.c_str());
bool subSource = relSource && relFromSource[0] != '.';
// 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] != '.';
......
......@@ -34,7 +34,7 @@
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
cmMakefile* mf)
: cmLocalCommonGenerator(gg, mf, cmOutputConverter::HOME_OUTPUT)
: cmLocalCommonGenerator(gg, mf, mf->GetState()->GetBinaryDirectory())
, HomeRelativeOutputPath("")
{
this->TargetImplib = "$TARGET_IMPLIB";
......@@ -51,7 +51,7 @@ void cmLocalNinjaGenerator::Generate()
// Compute the path to use when referencing the current output
// directory from the top output directory.
this->HomeRelativeOutputPath = this->ConvertToRelativePath(
this->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory());
if (this->HomeRelativeOutputPath == ".") {
this->HomeRelativeOutputPath = "";
}
......@@ -145,7 +145,8 @@ std::string cmLocalNinjaGenerator::ConvertToIncludeReference(
return this->ConvertToOutputFormat(cmSystemTools::CollapseFullPath(path),
format);
}
return this->Convert(path, cmOutputConverter::HOME_OUTPUT, format);
return this->ConvertToOutputFormat(
this->ConvertToRelativePath(this->GetBinaryDirectory(), path), format);
}
// Private methods.
......@@ -499,8 +500,10 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
const std::vector<std::string>& outputs = ccg.GetOutputs();
if (!outputs.empty()) {
if (ccg.GetWorkingDirectory().empty()) {
output = this->Convert(outputs[0], cmOutputConverter::START_OUTPUT,
cmOutputConverter::SHELL);
output = this->ConvertToOutputFormat(
this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(),
outputs[0]),
cmOutputConverter::SHELL);
} else {
output =
this->ConvertToOutputFormat(outputs[0], cmOutputConverter::SHELL);
......
......@@ -94,7 +94,7 @@ static std::string cmSplitExtension(std::string const& in, std::string& base)
cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3(
cmGlobalGenerator* gg, cmMakefile* mf)
: cmLocalCommonGenerator(gg, mf, cmOutputConverter::START_OUTPUT)
: cmLocalCommonGenerator(gg, mf, mf->GetCurrentBinaryDirectory())
{
this->MakefileVariableSize = 0;
this->ColorMakefile = false;
......@@ -151,7 +151,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->GetCurrentBinaryDirectory(), cmOutputConverter::HOME_OUTPUT);
this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory());
if (this->HomeRelativeOutputPath == ".") {
this->HomeRelativeOutputPath = "";
}
......@@ -556,8 +556,8 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
}
// Construct the left hand side of the rule.
std::string tgt = this->Convert(target, cmOutputConverter::HOME_OUTPUT,
cmOutputConverter::MAKERULE);
std::string tgt = cmSystemTools::ConvertToOutputPath(
this->ConvertToRelativePath(this->GetBinaryDirectory(), target).c_str());
const char* space = "";