diff options
Diffstat (limited to 'Source/cmLocalCommonGenerator.cxx')
-rw-r--r-- | Source/cmLocalCommonGenerator.cxx | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 5daaeff..211525a 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -9,14 +9,17 @@ #include "cmMakefile.h" #include "cmOutputConverter.h" #include "cmProperty.h" +#include "cmState.h" +#include "cmStateDirectory.h" +#include "cmStateSnapshot.h" #include "cmStringAlgorithms.h" class cmGlobalGenerator; cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmMakefile* mf, std::string wd) + cmMakefile* mf, WorkDir wd) : cmLocalGenerator(gg, mf) - , WorkingDirectory(std::move(wd)) + , WorkingDirectory(wd) { this->ConfigNames = this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); @@ -24,6 +27,23 @@ cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, cmLocalCommonGenerator::~cmLocalCommonGenerator() = default; +std::string const& cmLocalCommonGenerator::GetWorkingDirectory() const +{ + if (this->WorkingDirectory == WorkDir::TopBin) { + return this->GetState()->GetBinaryDirectory(); + } + return this->StateSnapshot.GetDirectory().GetCurrentBinary(); +} + +std::string cmLocalCommonGenerator::MaybeRelativeToWorkDir( + std::string const& path) const +{ + if (this->WorkingDirectory == WorkDir::TopBin) { + return this->MaybeRelativeToTopBinDir(path); + } + return this->MaybeRelativeToCurBinDir(path); +} + std::string cmLocalCommonGenerator::GetTargetFortranFlags( cmGeneratorTarget const* target, std::string const& config) { @@ -35,11 +55,10 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags( // Add a module output directory flag if necessary. std::string mod_dir = - target->GetFortranModuleDirectory(this->WorkingDirectory); + target->GetFortranModuleDirectory(this->GetWorkingDirectory()); if (!mod_dir.empty()) { mod_dir = this->ConvertToOutputFormat( - this->MaybeConvertToRelativePath(this->WorkingDirectory, mod_dir), - cmOutputConverter::SHELL); + this->MaybeRelativeToWorkDir(mod_dir), cmOutputConverter::SHELL); } else { mod_dir = this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT"); |