Fortran: Wrap path convert in a call with a more-suitable name

This commit is contained in:
Stephen Kelly
2016-10-04 22:56:31 +02:00
parent d5911ef014
commit 00173b71d9
2 changed files with 24 additions and 20 deletions

View File

@@ -198,16 +198,13 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
stamp += ".mod.stamp"; stamp += ".mod.stamp";
fcStream << "\n"; fcStream << "\n";
fcStream << " \"" fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(currentBinDir, << this->MaybeConvertToRelativePath(currentBinDir, mod_lower)
mod_lower)
<< "\"\n"; << "\"\n";
fcStream << " \"" fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(currentBinDir, << this->MaybeConvertToRelativePath(currentBinDir, mod_upper)
mod_upper)
<< "\"\n"; << "\"\n";
fcStream << " \"" fcStream << " \""
<< this->LocalGenerator->ConvertToRelativePath(currentBinDir, << this->MaybeConvertToRelativePath(currentBinDir, stamp)
stamp)
<< "\"\n"; << "\"\n";
} }
fcStream << " )\n"; fcStream << " )\n";
@@ -323,17 +320,16 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
// Write the include dependencies to the output stream. // Write the include dependencies to the output stream.
std::string binDir = this->LocalGenerator->GetBinaryDirectory(); std::string binDir = this->LocalGenerator->GetBinaryDirectory();
std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj); std::string obj_i = this->MaybeConvertToRelativePath(binDir, obj);
std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str()); std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
internalDepends << obj_i << std::endl; internalDepends << obj_i << std::endl;
internalDepends << " " << src << std::endl; internalDepends << " " << src << std::endl;
for (std::set<std::string>::const_iterator i = info.Includes.begin(); for (std::set<std::string>::const_iterator i = info.Includes.begin();
i != info.Includes.end(); ++i) { i != info.Includes.end(); ++i) {
makeDepends makeDepends << obj_m << ": "
<< obj_m << ": " << cmSystemTools::ConvertToOutputPath(
<< cmSystemTools::ConvertToOutputPath( this->MaybeConvertToRelativePath(binDir, *i).c_str())
this->LocalGenerator->ConvertToRelativePath(binDir, *i).c_str()) << std::endl;
<< std::endl;
internalDepends << " " << *i << std::endl; internalDepends << " " << *i << std::endl;
} }
makeDepends << std::endl; makeDepends << std::endl;
@@ -359,7 +355,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
proxy += *i; proxy += *i;
proxy += ".mod.proxy"; proxy += ".mod.proxy";
proxy = cmSystemTools::ConvertToOutputPath( proxy = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, proxy).c_str()); this->MaybeConvertToRelativePath(binDir, proxy).c_str());
// since we require some things add them to our list of requirements // since we require some things add them to our list of requirements
makeDepends << obj_m << ".requires: " << proxy << std::endl; makeDepends << obj_m << ".requires: " << proxy << std::endl;
@@ -375,8 +371,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
if (!required->second.empty()) { if (!required->second.empty()) {
// This module is known. Depend on its timestamp file. // This module is known. Depend on its timestamp file.
std::string stampFile = cmSystemTools::ConvertToOutputPath( std::string stampFile = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, required->second) this->MaybeConvertToRelativePath(binDir, required->second).c_str());
.c_str());
makeDepends << obj_m << ": " << stampFile << "\n"; makeDepends << obj_m << ": " << stampFile << "\n";
} else { } else {
// This module is not known to CMake. Try to locate it where // This module is not known to CMake. Try to locate it where
@@ -384,7 +379,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
std::string module; std::string module;
if (this->FindModule(*i, module)) { if (this->FindModule(*i, module)) {
module = cmSystemTools::ConvertToOutputPath( module = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, module).c_str()); this->MaybeConvertToRelativePath(binDir, module).c_str());
makeDepends << obj_m << ": " << module << "\n"; makeDepends << obj_m << ": " << module << "\n";
} }
} }
@@ -398,7 +393,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
proxy += *i; proxy += *i;
proxy += ".mod.proxy"; proxy += ".mod.proxy";
proxy = cmSystemTools::ConvertToOutputPath( proxy = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, proxy).c_str()); this->MaybeConvertToRelativePath(binDir, proxy).c_str());
makeDepends << proxy << ": " << obj_m << ".provides" << std::endl; makeDepends << proxy << ": " << obj_m << ".provides" << std::endl;
} }
@@ -420,14 +415,14 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
modFile += "/"; modFile += "/";
modFile += *i; modFile += *i;
modFile = this->LocalGenerator->ConvertToOutputFormat( modFile = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(binDir, modFile), this->MaybeConvertToRelativePath(binDir, modFile),
cmOutputConverter::SHELL); cmOutputConverter::SHELL);
std::string stampFile = stamp_dir; std::string stampFile = stamp_dir;
stampFile += "/"; stampFile += "/";
stampFile += m; stampFile += m;
stampFile += ".mod.stamp"; stampFile += ".mod.stamp";
stampFile = this->LocalGenerator->ConvertToOutputFormat( stampFile = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->ConvertToRelativePath(binDir, stampFile), this->MaybeConvertToRelativePath(binDir, stampFile),
cmOutputConverter::SHELL); cmOutputConverter::SHELL);
makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " << modFile makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " << modFile
<< " " << stampFile; << " " << stampFile;
@@ -448,7 +443,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
std::string driver = this->TargetDirectory; std::string driver = this->TargetDirectory;
driver += "/build"; driver += "/build";
driver = cmSystemTools::ConvertToOutputPath( driver = cmSystemTools::ConvertToOutputPath(
this->LocalGenerator->ConvertToRelativePath(binDir, driver).c_str()); this->MaybeConvertToRelativePath(binDir, driver).c_str());
makeDepends << driver << ": " << obj_m << ".provides.build\n"; makeDepends << driver << ": " << obj_m << ".provides.build\n";
} }
@@ -708,3 +703,9 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
// content. // content.
return cmFortranStreamsDiffer(finModFile, finStampFile); return cmFortranStreamsDiffer(finModFile, finStampFile);
} }
std::string cmDependsFortran::MaybeConvertToRelativePath(
std::string const& base, std::string const& path)
{
return this->LocalGenerator->ConvertToRelativePath(base, path);
}

View File

@@ -78,6 +78,9 @@ protected:
private: private:
cmDependsFortran(cmDependsFortran const&); // Purposely not implemented. cmDependsFortran(cmDependsFortran const&); // Purposely not implemented.
void operator=(cmDependsFortran const&); // Purposely not implemented. void operator=(cmDependsFortran const&); // Purposely not implemented.
std::string MaybeConvertToRelativePath(std::string const& base,
std::string const& path);
}; };
#endif #endif