diff options
-rw-r--r-- | Source/cmCommonTargetGenerator.cxx | 55 | ||||
-rw-r--r-- | Source/cmCommonTargetGenerator.h | 1 |
2 files changed, 32 insertions, 24 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 8a5746a..26ca375 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -105,36 +105,43 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags) } //---------------------------------------------------------------------------- +std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const +{ + std::string mod_dir; + const char* target_mod_dir = + this->Target->GetProperty("Fortran_MODULE_DIRECTORY"); + const char* moddir_flag = + this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG"); + if(target_mod_dir && moddir_flag) + { + // Compute the full path to the module directory. + if(cmSystemTools::FileIsFullPath(target_mod_dir)) + { + // Already a full path. + mod_dir = target_mod_dir; + } + else + { + // Interpret relative to the current output directory. + mod_dir = this->Makefile->GetCurrentBinaryDirectory(); + mod_dir += "/"; + mod_dir += target_mod_dir; + } + + // Make sure the module output directory exists. + cmSystemTools::MakeDirectory(mod_dir); + } + return mod_dir; +} + +//---------------------------------------------------------------------------- std::string cmCommonTargetGenerator::GetFortranModuleDirectory() { // Compute the module directory. if(!this->FortranModuleDirectoryComputed) { - const char* target_mod_dir = - this->Target->GetProperty("Fortran_MODULE_DIRECTORY"); - const char* moddir_flag = - this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG"); - if(target_mod_dir && moddir_flag) - { - // Compute the full path to the module directory. - if(cmSystemTools::FileIsFullPath(target_mod_dir)) - { - // Already a full path. - this->FortranModuleDirectory = target_mod_dir; - } - else - { - // Interpret relative to the current output directory. - this->FortranModuleDirectory = - this->Makefile->GetCurrentBinaryDirectory(); - this->FortranModuleDirectory += "/"; - this->FortranModuleDirectory += target_mod_dir; - } - - // Make sure the module output directory exists. - cmSystemTools::MakeDirectory(this->FortranModuleDirectory.c_str()); - } this->FortranModuleDirectoryComputed = true; + this->FortranModuleDirectory = this->ComputeFortranModuleDirectory(); } // Return the computed directory. diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 5fd976d..0a49e12 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -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); |