summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-03-03 21:53:33 (GMT)
committerBrad King <brad.king@kitware.com>2005-03-03 21:53:33 (GMT)
commit2444cd382847d0065233c8cedd7fe921babfe3c9 (patch)
tree5743407786dcc87ec6690b115df0b26db37bfd1a /Source
parent860a8e370c205543c1a484ec02bf813ab04df295 (diff)
downloadCMake-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')
-rw-r--r--Source/cmDependsFortran.cxx65
-rw-r--r--Source/cmDependsFortran.h5
-rw-r--r--Source/cmake.cxx11
3 files changed, 68 insertions, 13 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)
diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h
index 7cd920d..12456d7 100644
--- a/Source/cmDependsFortran.h
+++ b/Source/cmDependsFortran.h
@@ -39,6 +39,11 @@ public:
/** Virtual destructor to cleanup subclasses properly. */
virtual ~cmDependsFortran();
+ /** Callback from build system after a .mod file has been generated
+ by a Fortran90 compiler to copy the .mod file to the
+ corresponding stamp file. */
+ static bool CopyModule(const std::vector<std::string>& args);
+
/** Method to find an included file in the include path. Fortran
always searches the directory containing the including source
first. */
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index d48f85a..bfb6281 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -23,11 +23,12 @@
#include "cmCommand.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
+# include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback.
# include "cmVariableWatch.h"
# include "cmVersion.h"
#endif
-#include "cmLocalUnixMakefileGenerator2.h"
+#include "cmLocalUnixMakefileGenerator2.h" // For -E cmake_depends callback.
// only build kdevelop generator on non-windows platforms
// when not bootstrapping cmake
@@ -834,6 +835,14 @@ int cmake::CMakeCommand(std::vector<std::string>& args)
return cmLocalUnixMakefileGenerator2::ScanDependencies(args)? 0 : 1;
}
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ // Internal CMake Fortran module support.
+ else if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4)
+ {
+ return cmDependsFortran::CopyModule(args)? 0 : 1;
+ }
+#endif
+
#if defined(_WIN32) && !defined(__CYGWIN__)
// Write registry value
else if (args[1] == "write_regv" && args.size() > 3)