Bump various version numbers
[alexxy/gromacs.git] / cmake / gmxVersionInfo.cmake
index 6430211f29ef31c8f5be264db98ab49345e91246..162b32818e3d36046e31d45f4c2d84fc83b5a1de 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2014, by the GROMACS development team, led by
+# Copyright (c) 2014,2015, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
 #       Should always be defined: zero for, e.g., 5.0.
 #   GMX_VERSION_SUFFIX     String suffix to add to numeric version string.
 #       "-dev" is automatically added when not building from a source package,
-#       and does not need to be kept here.
-#   LIBRARY_SOVERSION      so version for the built libraries.
-#       Should be increased for each binary incompatible release (in GROMACS,
+#       and does not need to be kept here. This mechanism is not quite enough
+#       for building a tarball, but setting the CMake cache variable
+#       GMX_BUILD_TARBALL=on will suppress the addition of "-dev" to the
+#       version string.
+#   LIBRARY_SOVERSION_MAJOR so major version for the built libraries.
+#       Should be increased for each binary incompatible release. In GROMACS,
 #       the typical policy is to increase it for each major/minor version
 #       change, but not for patch releases, even if the latter may not always
-#       be fully binary compatible).
+#       be fully binary compatible.
+#   LIBRARY_SOVERSION_MINOR so minor version for the built libraries.
+#       Should be increased for each release that changes only the implementation.
+#       In GROMACS, the typical policy is to increase it for each patch version
+#       change, even if they may not always be fully binary compatible.
+#       If it is somehow clear that the ABI implementation has not changed
+#       in a patch release, this variable should not increase. Release candidate
+#       and beta versions will not increase this number, since nobody should
+#       write code against such versions.
 #   LIBRARY_VERSION        Full library version.
 #   REGRESSIONTEST_BRANCH  For builds not from source packages, name of the
 #       regressiontests branch at gerrit.gromacs.org whose HEAD can test this
 #       code, *if* this code is recent enough (i.e., contains all changes from
 #       the corresponding code branch that affects the regression test
-#       results).
+#       results). Even after a release branch is forked for the source
+#       repository, the correct regressiontests branch can still be master,
+#       because we do not fork it until behaviour needs to change.
 #   REGRESSIONTEST_MD5SUM
 #       The MD5 checksum of the regressiontest tarball. Only used when building
 #       from a source package.
@@ -83,6 +96,8 @@
 #   SOURCE_IS_GIT_REPOSITORY       The source tree is a git repository.
 # Note that both can be false if the tree has been extracted, e.g., as a
 # tarball directly from git.
+# Additionally, the following variable is defined:
+#   BUILD_IS_INSOURCE              The build is happening in-source.
 #
 # This script also declares machinery to generate and obtain version
 # information from a git repository.  This is enabled by default if the source
@@ -185,6 +200,10 @@ endif()
 if (NOT EXISTS "${PROJECT_SOURCE_DIR}/admin/.isreposource")
     set(SOURCE_IS_SOURCE_DISTRIBUTION ON)
 endif()
+set(BUILD_IS_INSOURCE OFF)
+if ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
+    set(BUILD_IS_INSOURCE ON)
+endif()
 
 #####################################################################
 # Manually maintained version info
@@ -192,19 +211,26 @@ endif()
 # The GROMACS convention is that these are the version number of the next
 # release that is going to be made from this branch.
 set(GMX_VERSION_MAJOR 5)
-set(GMX_VERSION_MINOR 1)
+set(GMX_VERSION_MINOR 2)
 set(GMX_VERSION_PATCH 0)
 # The suffix, on the other hand, is used mainly for betas and release
-# candidates, where it signifies the last such release from this branch;
-# it will be empty before the first such release, as well as after the
-# final release is out.
+# candidates, where it signifies the most recent such release from
+# this branch; it will be empty before the first such release, as well
+# as after the final release is out.
 set(GMX_VERSION_SUFFIX "")
 
-set(LIBRARY_SOVERSION 1)
-set(LIBRARY_VERSION ${LIBRARY_SOVERSION}.0.0)
-
-set(REGRESSIONTEST_BRANCH "refs/heads/master")
-set(REGRESSIONTEST_MD5SUM "a07524afebca5013540d4f2f72df2dce")
+# Conventionally with libtool, any ABI change must change the major
+# version number, the minor version number should change if it's just
+# the implementation that has been altered, and the third number
+# counts the number of old major versions that will still run if
+# linked to this library (i.e. it is not a patch number). See the
+# above descriptions of LIBRARY_SOVERSION_* for policy for changes
+# here. The important thing is to minimize the chance of third-party
+# code being able to dynamically link with a version of libgromacs
+# that might not work.
+set(LIBRARY_SOVERSION_MAJOR 2)
+set(LIBRARY_SOVERSION_MINOR 0)
+set(LIBRARY_VERSION ${LIBRARY_SOVERSION_MAJOR}.${LIBRARY_SOVERSION_MINOR}.0)
 
 #####################################################################
 # General version management based on manually set numbers
@@ -215,15 +241,23 @@ else()
     set(GMX_VERSION "${GMX_VERSION_MAJOR}.${GMX_VERSION_MINOR}")
 endif()
 set(GMX_VERSION_STRING "${GMX_VERSION}${GMX_VERSION_SUFFIX}")
-if (NOT SOURCE_IS_SOURCE_DISTRIBUTION)
+option(GMX_BUILD_TARBALL "Build tarball without -dev version suffix" OFF)
+mark_as_advanced(GMX_BUILD_TARBALL)
+if (NOT SOURCE_IS_SOURCE_DISTRIBUTION AND NOT GMX_BUILD_TARBALL)
     set(GMX_VERSION_STRING "${GMX_VERSION_STRING}-dev")
 endif()
 
 set(REGRESSIONTEST_VERSION "${GMX_VERSION_STRING}")
+set(REGRESSIONTEST_BRANCH "refs/heads/master")
+# TODO Find some way of ensuring that this is bumped appropriately for
+# each release. It's hard to test because it is only used for
+# REGRESSIONTEST_DOWNLOAD, which doesn't work until that tarball has
+# been placed on the server.
+set(REGRESSIONTEST_MD5SUM "6f8531a6e3c2a8912327b9cd450d8745" CACHE INTERNAL "MD5 sum of the regressiontests tarball")
 
 math(EXPR GMX_VERSION_NUMERIC
      "${GMX_VERSION_MAJOR}*10000 + ${GMX_VERSION_MINOR}*100 + ${GMX_VERSION_PATCH}")
-set(GMX_API_VERSION ${NUM_VERSION})
+set(GMX_API_VERSION ${GMX_VERSION_NUMERIC})
 
 #####################################################################
 # git version info management
@@ -342,7 +376,9 @@ function (gmx_configure_version_file INFILE OUTFILE)
     include(CMakeParseArguments)
     set(_options REMOTE_HASH SOURCE_FILE)
     set(_one_value_args COMMENT TARGET)
-    cmake_parse_arguments(ARG "${_options}" "${_one_value_args}" "" ${ARGN})
+    set(_multi_value_args EXTRA_VARS)
+    cmake_parse_arguments(
+        ARG "${_options}" "${_one_value_args}" "${_multi_value_args}" ${ARGN})
     if (ARG_UNPARSED_ARGUMENTS)
         message(FATAL_ERROR "Unknown arguments: ${ARG_UNPARSED_ARGUMENTS}")
     endif()
@@ -357,6 +393,11 @@ function (gmx_configure_version_file INFILE OUTFILE)
     if (NOT IS_ABSOLUTE ${INFILE})
         set(INFILE ${CMAKE_CURRENT_SOURCE_DIR}/${INFILE})
     endif()
+    # Create command-line definitions for the requested variables
+    set(_extra_var_defines)
+    foreach(_var ${ARG_EXTRA_VARS})
+        list(APPEND _extra_var_defines -D "${_var}=${${_var}}")
+    endforeach()
     # The touch command is necessary to ensure that after the target is run,
     # the timestamp is newer than in the input files.
     add_custom_command(OUTPUT ${OUTFILE}
@@ -364,6 +405,7 @@ function (gmx_configure_version_file INFILE OUTFILE)
             -D VERSION_VARIABLES=${VERSION_INFO_CMAKE_FILE}
             -D VERSION_CMAKEIN=${INFILE}
             -D VERSION_OUT=${OUTFILE}
+            ${_extra_var_defines}
             -P ${VERSION_INFO_CONFIGURE_SCRIPT}
         COMMAND ${CMAKE_COMMAND} -E touch ${OUTFILE}
         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}