diff options
author | Brad King <brad.king@kitware.com> | 2005-03-03 21:53:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2005-03-03 21:53:33 (GMT) |
commit | 2444cd382847d0065233c8cedd7fe921babfe3c9 (patch) | |
tree | 5743407786dcc87ec6690b115df0b26db37bfd1a /Source/cmDependsFortran.cxx | |
parent | 860a8e370c205543c1a484ec02bf813ab04df295 (diff) | |
download | CMake-2444cd382847d0065233c8cedd7fe921babfe3c9.zip CMake-2444cd382847d0065233c8cedd7fe921babfe3c9.tar.gz CMake-2444cd382847d0065233c8cedd7fe921babfe3c9.tar.bz2 |
ENH: Implementing explicit cmake_copy_f90_mod callback to copy Fortran90 modules to the stamp files more reliably. This removes the temporary hack for per-platform upper-/lower- case.
Diffstat (limited to 'Source/cmDependsFortran.cxx')
-rw-r--r-- | Source/cmDependsFortran.cxx | 65 |
1 files changed, 53 insertions, 12 deletions
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index e3c2a2e..a13c740 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -143,12 +143,8 @@ bool cmDependsFortran::WriteDependencies(std::ostream& os) // Require only modules not provided in the same source. if(parser.Provides.find(*i) == parser.Provides.end()) { - // Temporary hack for Fortran: choose case depending on platform -#if defined(__sgi) - std::string m = cmSystemTools::UpperCase(*i); -#else + // Always use lower case for the mod stamp file name. std::string m = cmSystemTools::LowerCase(*i); -#endif os << m_TargetFile.c_str() << ": " << m.c_str() << ".mod.stamp" << std::endl; os << m_TargetFile.c_str() << ".requires: " << i->c_str() << ".mod.proxy" @@ -182,14 +178,12 @@ bool cmDependsFortran::WriteDependencies(std::ostream& os) for(std::set<cmStdString>::const_iterator i = parser.Provides.begin(); i != parser.Provides.end(); ++i) { - // Temporary hack for Fortran: choose case depending on platform -#if defined(__sgi) - std::string m = cmSystemTools::UpperCase(*i); -#else + // Always use lower case for the mod stamp file name. The + // cmake_copy_f90_mod will call back to this class, which will + // try various cases for the real mod file name. std::string m = cmSystemTools::LowerCase(*i); -#endif - os << "\t@$(CMAKE_COMMAND) -E copy_if_different " - << m.c_str() << ".mod " << m.c_str() << ".mod.stamp\n"; + os << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " + << i->c_str() << " " << m.c_str() << ".mod.stamp\n"; } os << "\t@touch " << m_TargetFile.c_str() << ".provides\n"; } @@ -259,6 +253,53 @@ bool cmDependsFortran::CheckDependencies(std::istream&) } //---------------------------------------------------------------------------- +bool cmDependsFortran::CopyModule(const std::vector<std::string>& args) +{ + // Implements + // + // $(CMAKE_COMMAND) -E cmake_copy_f90_mod input.mod output.mod.stamp + // + // 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 + // compilers include a timestamp in the .mod file so it changes even + // when the interface described in the module does not. + + std::string mod = args[2]; + mod += ".mod"; + std::string stamp = args[3]; + std::string mod_upper = cmSystemTools::UpperCase(mod.c_str()); + std::string mod_lower = cmSystemTools::LowerCase(mod.c_str()); + + if(cmSystemTools::FileExists(mod_upper.c_str())) + { + if(!cmSystemTools::CopyFileIfDifferent(mod_upper.c_str(), stamp.c_str())) + { + std::cerr << "Error copying Fortran module from \"" + << mod_upper.c_str() << "\" to \"" << stamp.c_str() + << "\".\n"; + return false; + } + return true; + } + else if(cmSystemTools::FileExists(mod_lower.c_str())) + { + if(!cmSystemTools::CopyFileIfDifferent(mod_lower.c_str(), stamp.c_str())) + { + std::cerr << "Error copying Fortran module from \"" + << mod_lower.c_str() << "\" to \"" << stamp.c_str() + << "\".\n"; + return false; + } + return true; + } + + std::cerr << "Error copying Fortran module \"" << args[2].c_str() + << "\". Tried \"" << mod_upper.c_str() + << "\" and \"" << mod_lower.c_str() << "\".\n"; + return false; +} + +//---------------------------------------------------------------------------- bool cmDependsFortran::FindIncludeFile(const char* dir, const char* includeName, std::string& fileName) |