diff options
author | Brad King <brad.king@kitware.com> | 2015-07-29 17:07:02 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-07-29 17:37:54 (GMT) |
commit | e90372a0db3248d4b78d8d7d7020c66cb5dc3803 (patch) | |
tree | c1b2920bccbccaaebcdec3e587cefadea71400f5 /Source/cmCommonTargetGenerator.cxx | |
parent | 70c21301b274a28dde75b4f2adb141f9b170eb80 (diff) | |
download | CMake-e90372a0db3248d4b78d8d7d7020c66cb5dc3803.zip CMake-e90372a0db3248d4b78d8d7d7020c66cb5dc3803.tar.gz CMake-e90372a0db3248d4b78d8d7d7020c66cb5dc3803.tar.bz2 |
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.
Diffstat (limited to 'Source/cmCommonTargetGenerator.cxx')
-rw-r--r-- | Source/cmCommonTargetGenerator.cxx | 55 |
1 files changed, 31 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. |