#
# 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.
# 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
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
set(GMX_VERSION_MINOR 1)
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.
-set(GMX_VERSION_SUFFIX "")
-
-set(LIBRARY_SOVERSION 1)
-set(LIBRARY_VERSION ${LIBRARY_SOVERSION}.0.0)
+# 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 "-rc1")
-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 1)
+set(LIBRARY_SOVERSION_MINOR 0)
+set(LIBRARY_VERSION ${LIBRARY_SOVERSION_MAJOR}.${LIBRARY_SOVERSION_MINOR}.0)
#####################################################################
# General version management based on manually set numbers
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 "bb67f145095249e9d4a93227fc4c352e" 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
endif()
endif()
+include(gmxCustomCommandUtilities)
+
# The first two are also for use outside this file, encapsulating the details
# of how to use the generated VersionInfo.cmake.
set(VERSION_INFO_CMAKE_FILE ${PROJECT_BINARY_DIR}/VersionInfo.cmake)
# All targets added by gmx_configure_version_file() use the information
# from this script to get their variables from, removing the need to run
# git multiple times and simplifying reuse for other purposes.
- #
- # Ninja requires all generated files mentioned in dependencies of custom
- # commands (in gmx_configure_version_info()) to be actually mentioned in
- # the build system, and luckily add_custom_command() makes that possible.
- # But it seems impossible to create a robust custom command that would be
- # always run, so other generators that do not have this constraint simply
- # use an add_custom_target().
- if (CMAKE_GENERATOR STREQUAL "Ninja")
- # The second, phony file is never created, so the rule is always
- # triggered again. TODO: Figure out why this works, even though ninja
- # very eagerly complains about missing files.
- # This unfortunately does not work with the make generator, as
- # the non-existent second file causes some part of the generated system
- # erase the first file at the beginning of every build, causing a full
- # rebuild of the dependencies.
- add_custom_command(OUTPUT ${VERSION_INFO_CMAKE_FILE} git-version-phony
- COMMAND ${CMAKE_COMMAND}
- -D GIT_EXECUTABLE=${GIT_EXECUTABLE}
- -D PROJECT_VERSION=${GMX_VERSION_STRING}
- -D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
- -D VERSION_CMAKEIN=${VERSION_INFO_CMAKEIN_FILE_PARTIAL}
- -D VERSION_OUT=${VERSION_INFO_CMAKE_FILE}
- -P ${CMAKE_CURRENT_LIST_DIR}/gmxGenerateVersionInfo.cmake
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
- COMMENT "Generating git version information"
- VERBATIM)
- # The generated Ninja build system would probably work fine even
- # without this target, but CMake requires all custom commands to belong
- # to a target in the same CMakeLists.txt to generate anything for them.
- add_custom_target(git-version-info DEPENDS ${VERSION_INFO_CMAKE_FILE})
- else()
- # For other generators, a target-level dependency on git-version-info
- # ensures that VERSION_INFO_CMAKE_FILE is created before the dependent
- # target's dependencies are even evaluated.
- add_custom_target(git-version-info
- COMMAND ${CMAKE_COMMAND}
- -D GIT_EXECUTABLE=${GIT_EXECUTABLE}
- -D PROJECT_VERSION=${GMX_VERSION_STRING}
- -D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
- -D VERSION_CMAKEIN=${VERSION_INFO_CMAKEIN_FILE_PARTIAL}
- -D VERSION_OUT=${VERSION_INFO_CMAKE_FILE}
- -P ${CMAKE_CURRENT_LIST_DIR}/gmxGenerateVersionInfo.cmake
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
- COMMENT "Generating git version information"
- VERBATIM)
- endif()
+ gmx_add_custom_output_target(git-version-info RUN_ALWAYS
+ OUTPUT ${VERSION_INFO_CMAKE_FILE}
+ COMMAND ${CMAKE_COMMAND}
+ -D GIT_EXECUTABLE=${GIT_EXECUTABLE}
+ -D PROJECT_VERSION=${GMX_VERSION_STRING}
+ -D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
+ -D VERSION_CMAKEIN=${VERSION_INFO_CMAKEIN_FILE_PARTIAL}
+ -D VERSION_OUT=${VERSION_INFO_CMAKE_FILE}
+ -P ${CMAKE_CURRENT_LIST_DIR}/gmxGenerateVersionInfo.cmake
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ COMMENT "Generating git version information")
list(APPEND VERSION_INFO_DEPS git-version-info)
else()
# If the version info is static, just generate the CMake script with the
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()
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}
-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}
VERBATIM)
if (ARG_TARGET)
add_custom_target(${ARG_TARGET} DEPENDS ${OUTFILE} VERBATIM)
+ gmx_set_custom_target_output(${ARG_TARGET} ${OUTFILE})
endif()
if (ARG_SOURCE_FILE)
set_source_files_properties(${OUTFILE} PROPERTIES GENERATED true)