Skip to content

Add support for Trilinos_version_date.h and TRILINOS_VERSION_DATE macro (#4532)

James Willenbring requested to merge bartlettroscoe:4532-version-date into develop

Created by: bartlettroscoe

Adds default support for Trilinos_version_date.h and TRILINOS_VERSION_DATE macro as per #4532 (closed). When the .git/ directory exists and git 2.10.0 or greater is found, the file Trilinos_version_date.h will get generated automatically and installed along with the other header files for Trilinos. This allows us to get SPARC working again (see #4693 (closed)) and will enable all future customers to know the exact Trilinos version.

The documentation for this feature is in:

and is documented in the generated file Trilinos_version_date.h which, as of this PR branch looks like:

 * This macro gives the version date of the Trilinos git repository at
 * the time it was configured.  It gives the date YYYY-MM-DD and the 2-digit
 * (24) hour hh of the commit as a 10-digit integer:
 * As long as the branch for the git repo is not hard reset, the first-parent
 * history should give a monotonically increasing 10-digit integer.  This
 * 10-digit date/time integer YYYYMMDDhh will fit in a signed 32-bit integer
 * with a maximum value of 2^32 / 2 - 1 = 2147483647.  Therefore, the maximum
 * date that can be handled is the year 2147 with the max date/time of 2147 12
 * 31 23 = 2147123123.  Modern C/C++ compilers (and other implementations of
 * the C preprocesor) should be able to handle 32-bit integers.
 * This header file is meant to be included by downstream codes to determine
 * the version of Trilinos being used and allows
 * TRILINOS_VERSION_DATE to be used in C/C++ ifdefs like:
 * #if defined(TRILINOS_VERSION_DATE) && TRILINOS_VERSION_DATE >= 2019032704
 *   // The version is newer than 2019-03-27 04:00:00 UTC
 *   ...
 * #else
 *   // The version is older than 2019-03-27 04:00:00 UTC
 *     ...
 *  #endif
 * This allows downstream codes to know the fine-grained version of
 * Trilinos at configure and build time to adjust for the addition of
 * new features, deprecation of code, or breaks in backward compatibility
 * (which occur in specific commits with unique commit dates).

#define TRILINOS_VERSION_DATE 2019032810

There is strong automated testing for this feature in TriBITS (see

I also tested this branch '4532-version-date' on my machine 'crf450' using:

$ cd ~/Trilinos.base/BUILDS/ATDM/CHECKIN/

$ ./ sems-rhel6-gnu-7.2.0-openmp-release-debug \
  --enable-packages=Kokkos,Teuchos \
  --extra-cmake-options=-DCMAKE_INSTALL_PREFIX=${PWD}/sems-rhel6-gnu-7.2.0-openmp-release-debug/install \

$ cd sems-rhel6-gnu-7.2.0-openmp-release-debug/

$ ninja -j16 &> make.out

$ ninja -j16 install &> make.install.out

That installed the correct file with the correct version date:

$ grep "define TRILINOS_VERSION_DATE" install/include/Trilinos_version_date.h 
#define TRILINOS_VERSION_DATE 2019032810

That looks correct given:

$ cd Trilinos/

$ env TZ=GMT git log --format="%cd" --date=iso-local -1 HEAD
2019-03-28 10:11:25 +0000

NOTE: This also brings in some other unrelated stuff on TriBITS 'master' due to the snapshotting process (see here).

Merge request reports