cmCommonTargetGenerator: Factor out Fortran module directory computation

Move computation from GetFortranModuleDirectory to a virtual method
so it can be customized for each type of generator.
This commit is contained in:
Brad King 2015-07-29 13:07:02 -04:00
parent 70c21301b2
commit e90372a0db
2 changed files with 32 additions and 24 deletions

View File

@ -105,11 +105,9 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
}
//----------------------------------------------------------------------------
std::string cmCommonTargetGenerator::GetFortranModuleDirectory()
std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const
{
// Compute the module directory.
if(!this->FortranModuleDirectoryComputed)
{
std::string mod_dir;
const char* target_mod_dir =
this->Target->GetProperty("Fortran_MODULE_DIRECTORY");
const char* moddir_flag =
@ -120,21 +118,30 @@ std::string cmCommonTargetGenerator::GetFortranModuleDirectory()
if(cmSystemTools::FileIsFullPath(target_mod_dir))
{
// Already a full path.
this->FortranModuleDirectory = target_mod_dir;
mod_dir = target_mod_dir;
}
else
{
// Interpret relative to the current output directory.
this->FortranModuleDirectory =
this->Makefile->GetCurrentBinaryDirectory();
this->FortranModuleDirectory += "/";
this->FortranModuleDirectory += target_mod_dir;
mod_dir = this->Makefile->GetCurrentBinaryDirectory();
mod_dir += "/";
mod_dir += target_mod_dir;
}
// Make sure the module output directory exists.
cmSystemTools::MakeDirectory(this->FortranModuleDirectory.c_str());
cmSystemTools::MakeDirectory(mod_dir);
}
return mod_dir;
}
//----------------------------------------------------------------------------
std::string cmCommonTargetGenerator::GetFortranModuleDirectory()
{
// Compute the module directory.
if(!this->FortranModuleDirectoryComputed)
{
this->FortranModuleDirectoryComputed = true;
this->FortranModuleDirectory = this->ComputeFortranModuleDirectory();
}
// Return the computed directory.

View File

@ -62,6 +62,7 @@ protected:
bool FortranModuleDirectoryComputed;
std::string FortranModuleDirectory;
std::string GetFortranModuleDirectory();
virtual std::string ComputeFortranModuleDirectory() const;
// Compute target-specific Fortran language flags.
void AddFortranFlags(std::string& flags);