Skip to content
Snippets Groups Projects
MantidVersion.cpp.in 3.06 KiB
Newer Older
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidKernel/MantidVersion.h"

#include <sstream>

namespace Mantid
{
namespace Kernel
{

const char* MantidVersion::version()
{
  // The major and minor version numbers are specified in Build/CMake/VersionNumber.cmake
  // The patch number is the number of commits since the most recent tag of the repository
  return "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@";
const char* MantidVersion::versionShort()
{
  // The major and minor version numbers are specified in Build/CMake/VersionNumber.cmake
  return "@VERSION_MAJOR@.@VERSION_MINOR@";
}

std::string MantidVersion::releaseNotes()
{
  const std::string STEM = "qthelp://org.mantidproject/doc/release/v";
  const std::string END = "/index.html";
  // Cast here in those cases where patch number is of the form 20131022.1356.
  const unsigned int patchVersion = static_cast<unsigned int>(@VERSION_PATCH@);

  // For major/minor/patch releases we point users to a specific release-notes, for
  // dev versions we point to the next main release notes.  A simple way to see whether or not
  // we're currently in a dev version is to check if the patch version is larger than
  // some arbitrarily low value.

  // for now the code assumes that the next main release version number will be one minor version higher

  std::stringstream versionLabel;

  if ( patchVersion < 100 ) {
    versionLabel << versionShort();
    versionLabel << "." << patchVersion;
  }
  else {
    const unsigned int minorVersion = static_cast<unsigned int>(@VERSION_MINOR@);
    versionLabel << "@VERSION_MAJOR@." << minorVersion + 1  << "." << "0";
  }

  std::stringstream url;
  url << STEM << versionLabel.str() << END;
const char* MantidVersion::revision()
{
  return "@MtdVersion_WC_LAST_CHANGED_SHA@";
const char* MantidVersion::revisionFull()
{
  return "@MtdVersion_WC_LAST_CHANGED_SHA_LONG@";
}

const char* MantidVersion::releaseDate()
{
  return "@MtdVersion_WC_LAST_CHANGED_DATE@";
}

std::string MantidVersion::doi()
  const std::string MAIN = "http://dx.doi.org/10.5286/Software/Mantid";
  // Cast here in those cases where patch number is of the form 20131022.1356.
  const unsigned int patchVersion = static_cast<unsigned int>(@VERSION_PATCH@);
  // For major/minor/patch releases we point users to a specific release-notes DOI, for
  // dev versions we just point to the main DOI.  A simple way to see whether or not
  // we're currently in a dev version is to check if the patch version is larger than
  // some arbitrarily low value.
  if( patchVersion > 100 )
    return MAIN;

  std::stringstream doi;
  doi << MAIN << @VERSION_MAJOR@ << "." << @VERSION_MINOR@;
  // Keep to the convention where we write a version number like "3.0.0" as "3.0".
  if( patchVersion != 0 )
    doi << "." << patchVersion;

  return doi.str();
}

std::string MantidVersion::paperCitation()
{
  return "http://dx.doi.org/10.1016/j.nima.2014.07.029";
}

} // namespace Kernel
} // namespace Mantid