Use CMake project versioning convention.
authorM. Eric Irrgang <ericirrgang@gmail.com>
Mon, 25 Oct 2021 15:39:58 +0000 (18:39 +0300)
committerM. Eric Irrgang <ericirrgang@gmail.com>
Wed, 27 Oct 2021 12:40:00 +0000 (12:40 +0000)
* Set CMP0048 policy to NEW behavior.
* Set MAJOR and MINOR version in the main project() command. Update
  `cmake/gmxVersionInfo.cmake` to set from PROJECT_VERSION_MAJOR and
  PROJECT_VERSION_MINOR.

Fixes #3725

CMakeLists.txt
cmake/gmxVersionInfo.cmake

index db54d2387138d8be3cabe4b33457c2cdd309e770..2799c2f8281e2e49e618005057377740da0f7874 100644 (file)
@@ -37,6 +37,7 @@
 cmake_minimum_required(VERSION 3.16.3)
 cmake_policy(SET CMP0074 NEW) # From CMake 3.12
 cmake_policy(SET CMP0068 NEW) # From CMake-3.9
+cmake_policy(SET CMP0048 NEW) # As of CMake 3.22, default is still "OLD"
 
 # CMake modules/macros are in a subdirectory to keep this file cleaner
 # This needs to be set before project() in order to pick up toolchain files
@@ -53,7 +54,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
         FORCE)
 endif()
 
-project(Gromacs)
+# The GROMACS convention is that these are the version number of the next
+# release that is going to be made from this branch.
+project(Gromacs VERSION 2022.0)
 
 set(CMAKE_CXX_STANDARD 17)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
index 20904e5427f218bfe8b9a55c48a8fe3ca5f31a5c..851bbd146acdeb3cf52c465e1e1e43ddbfffe626 100644 (file)
 # Sets version information variables and provides CMake functions for
 # generating files based on them
 #
-# This script provides the following basic version variables that need to be
-# maintained manually:
+# The following variables are derived from variables initialized by
+# https://cmake.org/cmake/help/latest/command/project.html#command:project
 #   GMX_VERSION_MAJOR      Major version number.
 #   GMX_VERSION_PATCH      Patch version number.
 #       Should always be defined: zero for, e.g., 2016.
+#
+# This script provides the following basic version variables that need to be
+# maintained manually:
 #   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. This mechanism is not quite enough
 # The scripts gmxGenerateVersionInfo.cmake and gmxConfigureVersionInfo.cmake
 # are used internally by this machinery, as well as VersionInfo.cmake.cmakein.
 
+#####################################################################
+# Derived version info.
+# Ref https://cmake.org/cmake/help/latest/command/project.html#command:project
+set(GMX_VERSION_MAJOR ${Gromacs_VERSION_MAJOR})
+set(GMX_VERSION_PATCH ${Gromacs_VERSION_MINOR})
+
 #####################################################################
 # Manually maintained version info
 
-# 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 2022)
-set(GMX_VERSION_PATCH 0)
-# The suffix, on the other hand, is used mainly for betas and release
+# The suffix is used mainly for betas and release
 # 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.