diff options
author | Brad King <brad.king@kitware.com> | 2014-06-23 14:01:40 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-06-23 14:01:40 (GMT) |
commit | 3ec3b8a926a921113d6232e3b9aaf20acfd746fb (patch) | |
tree | b4e25465bb457afc4ff257da63f5b3f016b0c626 | |
parent | 15c6d352efa66b85a2cde06b7ccb1ef2b9458439 (diff) | |
parent | d90be200ecdfd35395f7fdd1f82ddcd4006a256e (diff) | |
download | CMake-3ec3b8a926a921113d6232e3b9aaf20acfd746fb.zip CMake-3ec3b8a926a921113d6232e3b9aaf20acfd746fb.tar.gz CMake-3ec3b8a926a921113d6232e3b9aaf20acfd746fb.tar.bz2 |
Merge branch 'gfortran-compressed-modules' into release
-rw-r--r-- | Source/cmDependsFortran.cxx | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index d5472a1..e4a146c 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -765,7 +765,11 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile, const char* compilerId) { /* - gnu: + gnu >= 4.9: + A mod file is an ascii file compressed with gzip. + Compiling twice produces identical modules. + + gnu < 4.9: A mod file is an ascii file. <bar.mod> FORTRAN module created from /path/to/foo.f90 on Sun Dec 30 22:47:58 2007 @@ -821,21 +825,30 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile, */ if (strcmp(compilerId, "GNU") == 0 ) { - const char seq[1] = {'\n'}; - const int seqlen = 1; - - if(!cmDependsFortranStreamContainsSequence(finModFile, seq, seqlen)) + // GNU Fortran 4.9 and later compress .mod files with gzip + // but also do not include a date so we can fall through to + // compare them without skipping any prefix. + unsigned char hdr[2]; + bool okay = finModFile.read(reinterpret_cast<char*>(hdr), 2)? true:false; + finModFile.seekg(0); + if(!(okay && hdr[0] == 0x1f && hdr[1] == 0x8b)) { - // The module is of unexpected format. Assume it is different. - std::cerr << compilerId << " fortran module " << modFile - << " has unexpected format." << std::endl; - return true; - } + const char seq[1] = {'\n'}; + const int seqlen = 1; - if(!cmDependsFortranStreamContainsSequence(finStampFile, seq, seqlen)) - { - // The stamp must differ if the sequence is not contained. - return true; + if(!cmDependsFortranStreamContainsSequence(finModFile, seq, seqlen)) + { + // The module is of unexpected format. Assume it is different. + std::cerr << compilerId << " fortran module " << modFile + << " has unexpected format." << std::endl; + return true; + } + + if(!cmDependsFortranStreamContainsSequence(finStampFile, seq, seqlen)) + { + // The stamp must differ if the sequence is not contained. + return true; + } } } else if(strcmp(compilerId, "Intel") == 0) |