ENH: Make the Fortran compiler id available to cmDependsFortran at scanning and module timestamp copy time.

This commit is contained in:
Brad King 2008-01-02 11:04:52 -05:00
parent c8b8e0c702
commit c7de81f9a6
3 changed files with 35 additions and 5 deletions

View File

@ -536,7 +536,14 @@ cmDependsFortran
cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::SHELL); cmLocalGenerator::SHELL);
makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod "
<< modFile << " " << stampFile << "\n"; << modFile << " " << stampFile;
cmMakefile* mf = this->LocalGenerator->GetMakefile();
const char* cid = mf->GetDefinition("CMAKE_Fortran_COMPILER_ID");
if(cid && *cid)
{
makeDepends << " " << cid;
}
makeDepends << "\n";
} }
// After copying the modules update the timestamp file so that // After copying the modules update the timestamp file so that
// copying will not be done again until the source rebuilds. // copying will not be done again until the source rebuilds.
@ -600,6 +607,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
// Implements // Implements
// //
// $(CMAKE_COMMAND) -E cmake_copy_f90_mod input.mod output.mod.stamp // $(CMAKE_COMMAND) -E cmake_copy_f90_mod input.mod output.mod.stamp
// [compiler-id]
// //
// Note that the case of the .mod file depends on the compiler. In // Note that the case of the .mod file depends on the compiler. In
// the future this copy could also account for the fact that some // the future this copy could also account for the fact that some
@ -608,6 +616,11 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
std::string mod = args[2]; std::string mod = args[2];
std::string stamp = args[3]; std::string stamp = args[3];
std::string compilerId;
if(args.size() >= 5)
{
compilerId = args[4];
}
std::string mod_dir = cmSystemTools::GetFilenamePath(mod); std::string mod_dir = cmSystemTools::GetFilenamePath(mod);
if(!mod_dir.empty()) { mod_dir += "/"; } if(!mod_dir.empty()) { mod_dir += "/"; }
std::string mod_upper = mod_dir; std::string mod_upper = mod_dir;
@ -619,7 +632,8 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
mod_lower += ".mod"; mod_lower += ".mod";
if(cmSystemTools::FileExists(mod_upper.c_str(), true)) if(cmSystemTools::FileExists(mod_upper.c_str(), true))
{ {
if(cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str())) if(cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
compilerId.c_str()))
{ {
if(!cmSystemTools::CopyFileAlways(mod_upper.c_str(), stamp.c_str())) if(!cmSystemTools::CopyFileAlways(mod_upper.c_str(), stamp.c_str()))
{ {
@ -633,7 +647,8 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
} }
else if(cmSystemTools::FileExists(mod_lower.c_str(), true)) else if(cmSystemTools::FileExists(mod_lower.c_str(), true))
{ {
if(cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str())) if(cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
compilerId.c_str()))
{ {
if(!cmSystemTools::CopyFileAlways(mod_lower.c_str(), stamp.c_str())) if(!cmSystemTools::CopyFileAlways(mod_lower.c_str(), stamp.c_str()))
{ {
@ -654,8 +669,10 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmDependsFortran::ModulesDiffer(const char* modFile, bool cmDependsFortran::ModulesDiffer(const char* modFile,
const char* stampFile) const char* stampFile,
const char* compilerId)
{ {
(void)compilerId;
/* /*
This following is valid for intel and gnu. For others this may be valid This following is valid for intel and gnu. For others this may be valid
too, but has to be proven. too, but has to be proven.

View File

@ -48,7 +48,8 @@ public:
/** Determine if a mod file and the corresponding mod.stamp file /** Determine if a mod file and the corresponding mod.stamp file
are representing different module information. */ are representing different module information. */
static bool ModulesDiffer(const char* modFile, const char* stampFile); static bool ModulesDiffer(const char* modFile, const char* stampFile,
const char* compilerId);
/** Method to find an included file in the include path. Fortran /** Method to find an included file in the include path. Fortran
always searches the directory containing the including source always searches the directory containing the including source

View File

@ -1780,6 +1780,18 @@ void cmLocalUnixMakefileGenerator3
cmakefileStream << "\"" << pi->first << "\"\n"; cmakefileStream << "\"" << pi->first << "\"\n";
} }
cmakefileStream << " )\n"; cmakefileStream << " )\n";
// Tell the dependency scanner what compiler is used.
std::string cidVar = "CMAKE_";
cidVar += l->first;
cidVar += "_COMPILER_ID";
const char* cid = this->Makefile->GetDefinition(cidVar.c_str());
if(cid && *cid)
{
cmakefileStream
<< "SET(CMAKE_" << l->first.c_str() << "_COMPILER_ID \""
<< cid << "\")\n";
}
} }
} }