2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2014,2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
35 # Sets version information variables and provides CMake functions for
36 # generating files based on them
38 # This script provides the following basic version variables that need to be
39 # maintained manually:
40 # GMX_VERSION_MAJOR Major version number.
41 # GMX_VERSION_PATCH Patch version number.
42 # Should always be defined: zero for, e.g., 2016.
43 # GMX_VERSION_SUFFIX String suffix to add to numeric version string.
44 # "-dev" is automatically added when not building from a source package,
45 # and does not need to be kept here. This mechanism is not quite enough
46 # for building a tarball, but setting the CMake cache variable
47 # GMX_BUILD_TARBALL=on will suppress the addition of "-dev" to the
49 # LIBRARY_SOVERSION_MAJOR so major version for the built libraries.
50 # Should be increased for each binary incompatible release. In GROMACS,
51 # the typical policy is to increase it at the start of the development
52 # cycle for each major/minor version change, but not for patch releases,
53 # even if the latter may not always be fully binary compatible.
54 # Table of historical values
62 # LIBRARY_SOVERSION_MINOR so minor version for the built libraries.
63 # Should be increased for each release that changes only the implementation.
64 # In GROMACS, the typical policy is to increase it for each patch version
65 # change, even if they may not always be fully binary compatible.
66 # If it is somehow clear that the ABI implementation has not changed
67 # in a patch release, this variable should not increase. Release candidate
68 # and beta versions will not increase this number, since nobody should
69 # write code against such versions.
70 # LIBRARY_VERSION Full library version.
71 # REGRESSIONTEST_BRANCH For builds not from source packages, name of the
72 # regressiontests branch at gerrit.gromacs.org whose HEAD can test this
73 # code, *if* this code is recent enough (i.e., contains all changes from
74 # the corresponding code branch that affects the regression test
75 # results). Even after a release branch is forked for the source
76 # repository, the correct regressiontests branch can still be master,
77 # because we do not fork it until behaviour needs to change.
78 # REGRESSIONTEST_MD5SUM
79 # The MD5 checksum of the regressiontest tarball. Only used when building
80 # from a source package.
82 # ID collected from Zenodo connected to the doi for a released version
83 # used to identify the source when building an official released version.
84 # This ID is used for the source code tarball.
86 # Same as above, but for the reference manual.
87 # They are collected into a single section below.
88 # The following variables are set based on these:
89 # GMX_VERSION String composed from GMX_VERSION_* numeric variables
90 # above. Example: 4.6.1, 5.0, 2016
91 # GMX_VERSION_STRING String with GMX_VERSION suffixed with the given
92 # suffix and possibly "-dev" for builds not from a source package.
93 # GMX_VERSION_NUMERIC Numeric version number (e.g., 40601 for 4.6.1, 20160001 for 2016.1).
94 # GMX_API_VERSION Numeric API version.
95 # This is currently set automatically to GMX_VERSION_NUMERIC, but may
96 # become manually maintained in the future if there will be releases
97 # where the API does not change, but programs/libraries do.
98 # In such a case, this should be the first version where the current API
100 # REGRESSIONTEST_VERSION For source packages, version number of the
101 # matching regressiontests tarball. Not used for builds not from source
103 # The latter two are used to generate gromacs/version.h to allow software
104 # written against the GROMACS API to provide some #ifdef'ed code to support
105 # multiple GROMACS versions.
107 # This script also declares machinery to generate and obtain version
108 # information from a git repository. This is enabled by default if the source
109 # tree is a git, but can be disabled with
110 # GMX_GIT_VERSION_INFO Advanced CMake variable to disable git
111 # version info generation.
112 # If the version generation is disabled, then the source and manual doi
113 # will be based on the stored values for the ID.
114 # The main interface to this machinery is the gmx_configure_version_file()
115 # CMake function. The signature is
116 # gmx_configure_version_file(<input> <output>
119 # [COMMENT <comment>])
120 # <input> Specify the input and output files as for configure_file().
121 # <output> The configuration is done with configure_file(... @ONLY) with
122 # the following variables defined (as well as all the
123 # GMX_VERSION* variables from above):
124 # GMX_VERSION_STRING_FULL
125 # GMX_VERSION_FULL_HASH
126 # GMX_VERSION_CENTRAL_BASE_HASH
127 # The output file is created during build time, so any dependent
128 # targets should specify it as a dependency.
129 # REMOTE_HASH Currently, this has no effect, but it signifies that the
130 # <input> file is using the CENTRAL_BASE_HASH variable.
131 # This variable is much more expensive to initialize than the
132 # others, so this allows local changes in this file to only
133 # compute that value when required if that becomes necessary.
134 # TARGET By default, this function uses add_custom_command() to
135 # generate the output file. If TARGET is specified, then
136 # add_custom_target() is used to create a target with the given
137 # name <target> that runs this custom command. Use this if
138 # the same file will be used for multiple downstream targets,
139 # or if the explicit target for the file is otherwise
141 # COMMENT Set a custom comment to be shown when building the rule
142 # (see add_custom_command(... COMMENT <comment>)).
143 # As an alternative to using this script, also the following variables are
144 # provided (can be useful when generating more complex CMake scripts that do
146 # VERSION_INFO_CMAKE_SCRIPT
147 # Absolute path to a CMake script that can be included using include()
148 # to declare the GMX_VERSION_* variables documented for
149 # gmx_configure_version_file().
151 # If a custom command depends on VERSION_INFO_CMAKE_SCRIPT, then it
152 # should add ${VERSION_INFO_DEPS} to its DEPENDS list to get the
153 # appropriate dependencies.
154 # TODO: If someone wants to add a custom target that depends on
155 # VERSION_INFO_CMAKE_SCRIPT, a separate variable may be needed for those
158 # The version string printed by 'gmx -version' (and also printed in the startup
159 # header) can provide useful information for, e.g., diagnosing bug reports and
160 # identifying what exact version the user was using. The following formats are
161 # possible (with examples given for a particular version):
162 # 2018.1 Plain version number without any suffix signifies a build from
163 # a released source tarball.
164 # 2018.1-dev '-dev' suffix signifies all other builds. If there is no other
165 # information, either the user built the code outside any git
166 # repository, or disabled the version info generation.
167 # 2018.1-dev-YYYYMMDD-1234abc
168 # The YYYYMMDD part shows the commit date (not author date) of
169 # the HEAD commit from which the code was built. The abbreviated
170 # hash is the hash of that commit (the full hash is available in
171 # 'gmx -version' output).
172 # If the HEAD hash is not identified as coming from branches in
173 # "authoritative" GROMACS repositories, 'gmx -version' will show
174 # the nearest ancestor commit that is identified as such (but see
175 # the '-local' and '-unknown' suffixes below).
176 # 2018.1-dev-YYYYMMDD-1234abc-dirty
177 # As above, but there were local modifications in the source tree
178 # when the code was built.
179 # 2018.1-dev-YYYYMMDD-1234abc-unknown
180 # As above, but there were no remotes in the repository that
181 # could be identified as "authoritative" GROMACS repositories.
182 # This happens if the code is not cloned from git.gromacs.org
183 # or gerrit.gromacs.org.
184 # 2018.1-dev-YYYYMMDD-1234abc-local
185 # As above, but there were no commits in the recent history of
186 # the branch that could be identified as coming from
187 # "authoritative" GROMACS repositories. This should be
190 # Other variables set here are not intended for use outside this file.
191 # The scripts gmxGenerateVersionInfo.cmake and gmxConfigureVersionInfo.cmake
192 # are used internally by this machinery, as well as VersionInfo.cmake.cmakein.
194 #####################################################################
195 # Manually maintained version info
197 # The GROMACS convention is that these are the version number of the next
198 # release that is going to be made from this branch.
199 set(GMX_VERSION_MAJOR 2021)
200 set(GMX_VERSION_PATCH 0)
201 # The suffix, on the other hand, is used mainly for betas and release
202 # candidates, where it signifies the most recent such release from
203 # this branch; it will be empty before the first such release, as well
204 # as after the final release is out.
205 set(GMX_VERSION_SUFFIX "")
207 # Conventionally with libtool, any ABI change must change the major
208 # version number, the minor version number should change if it's just
209 # the implementation that has been altered, and the third number
210 # counts the number of old major versions that will still run if
211 # linked to this library (i.e. it is not a patch number). See the
212 # above descriptions of LIBRARY_SOVERSION_* for policy for changes
213 # here. The important thing is to minimize the chance of third-party
214 # code being able to dynamically link with a version of libgromacs
215 # that might not work.
216 set(LIBRARY_SOVERSION_MAJOR 6)
217 set(LIBRARY_SOVERSION_MINOR 0)
218 set(LIBRARY_VERSION ${LIBRARY_SOVERSION_MAJOR}.${LIBRARY_SOVERSION_MINOR}.0)
220 #####################################################################
221 # General version management based on manually set numbers
223 if (GMX_VERSION_PATCH)
224 set(GMX_VERSION "${GMX_VERSION_MAJOR}.${GMX_VERSION_PATCH}")
226 set(GMX_VERSION "${GMX_VERSION_MAJOR}")
228 set(GMX_VERSION_STRING "${GMX_VERSION}${GMX_VERSION_SUFFIX}")
230 # If you are making a custom fork of GROMACS, please describe your
231 # fork, perhaps with its version number, in the value of
232 # GMX_VERSION_STRING_OF_FORK here. This string will appear in the
233 # header of log files that mdrun writes. This will help you, your
234 # users, your system administrators, your maintainers and the
235 # maintainers of GROMACS core understand how to troubleshoot and
236 # reproduce potential problems.
238 # If you are distributing a patch to GROMACS, then this change would
239 # be great as part of your patch. Otherwise for personal use, you can
240 # also just set a CMake cache variable.
241 set(GMX_VERSION_STRING_OF_FORK "" CACHE INTERNAL
242 "Version string for forks of GROMACS to set to describe themselves")
243 mark_as_advanced(GMX_VERSION_STRING_OF_FORK)
244 if (GMX_VERSION_STRING_OF_FORK)
245 set(GMX_VERSION_STRING "${GMX_VERSION_STRING}-${GMX_VERSION_STRING_OF_FORK}")
248 option(GMX_BUILD_TARBALL "Build tarball without -dev version suffix" OFF)
249 mark_as_advanced(GMX_BUILD_TARBALL)
250 # If run with cmake -P, the -dev suffix is managed elsewhere.
251 if (NOT SOURCE_IS_SOURCE_DISTRIBUTION AND
252 NOT GMX_BUILD_TARBALL AND
253 NOT CMAKE_SCRIPT_MODE_FILE)
254 set(GMX_VERSION_STRING "${GMX_VERSION_STRING}-dev")
257 set(REGRESSIONTEST_VERSION "${GMX_VERSION_STRING}")
258 set(REGRESSIONTEST_BRANCH "refs/heads/master")
259 # Run the regressiontests packaging job with the correct pakage
260 # version string, and the release box checked, in order to have it
261 # build the regressiontests tarball with all the right naming. The
262 # naming affects the md5sum that has to go here, and if it isn't right
263 # release workflow will report a failure.
264 set(REGRESSIONTEST_MD5SUM "42e3bfe74a8e8bf8e38919e10aaf8fa1" CACHE INTERNAL "MD5 sum of the regressiontests tarball for this GROMACS version")
266 math(EXPR GMX_VERSION_NUMERIC
267 "${GMX_VERSION_MAJOR}*10000 + ${GMX_VERSION_PATCH}")
268 set(GMX_API_VERSION ${GMX_VERSION_NUMERIC})
270 # If run with cmake -P from releng scripts, print out necessary version info
272 if (CMAKE_SCRIPT_MODE_FILE)
273 message("{ \"version\": \"${GMX_VERSION_STRING}\", \"regressiontest-md5sum\": \"${REGRESSIONTEST_MD5SUM}\" }")
277 # Set those values only in release versions, after getting the identifiers
278 # from Zenodo for the manual and source code
279 # Has to be done by hand before every final release
280 # Use force to override anything given as a cmake command line input
281 # Actual input depends on the GMX_VERSION_STRING_OF_FORK variable being set or not.
282 # If it is set, we always default to an empty string, otherwise to the value set for the release build.
283 if (GMX_VERSION_STRING_OF_FORK)
284 set(GMX_MANUAL_DOI_INTERNAL "")
285 set(GMX_SOURCE_DOI_INTERNAL "")
287 set(GMX_MANUAL_DOI_INTERNAL "") # Set correct doi string here
288 set(GMX_SOURCE_DOI_INTERNAL "") # Set correct doi string here
290 set(GMX_MANUAL_DOI ${GMX_MANUAL_DOI_INTERNAL} CACHE INTERNAL "reserved doi for GROMACS manual" FORCE)
291 set(GMX_SOURCE_DOI ${GMX_SOURCE_DOI_INTERNAL} CACHE INTERNAL "reserved doi for GROMACS source code" FORCE)
293 #####################################################################
294 # git version info management
296 # There can be clusters where git and CMake can run on nodes where the other is
297 # not available, accessing the same source tree.
298 # Should be unlikely, but doesn't hurt to check.
299 set(_git_info_default OFF)
300 if (SOURCE_IS_GIT_REPOSITORY)
303 set(_git_info_default ON)
306 option(GMX_GIT_VERSION_INFO "Generate git version information" ${_git_info_default})
307 mark_as_advanced(GMX_GIT_VERSION_INFO)
308 # Detect preconditions for version info generation if it is requested.
309 if (GMX_GIT_VERSION_INFO)
310 if (NOT SOURCE_IS_GIT_REPOSITORY)
312 "Cannot generate git version information from source tree not under git. "
313 "Set GMX_GIT_VERSION_INFO=OFF to proceed.")
315 # We need at least git v1.5.3 be able to parse git's date output.
316 if (NOT GIT_FOUND OR GIT_VERSION_STRING VERSION_LESS "1.5.3")
318 "No compatible git version found (>= 1.5.3 required). "
319 "Won't be able to generate development version information. "
320 "Set GMX_GIT_VERSION_INFO=OFF to proceed.")
324 include(gmxCustomCommandUtilities)
326 # The first two are also for use outside this file, encapsulating the details
327 # of how to use the generated VersionInfo.cmake.
328 set(VERSION_INFO_CMAKE_FILE ${PROJECT_BINARY_DIR}/VersionInfo.cmake)
329 set(VERSION_INFO_DEPS ${VERSION_INFO_CMAKE_FILE})
330 # Capture the location of the necessary files in internal variables for use in
331 # the function below.
332 set(VERSION_INFO_CMAKEIN_FILE ${CMAKE_CURRENT_LIST_DIR}/VersionInfo.cmake.cmakein)
333 set(VERSION_INFO_CONFIGURE_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/gmxConfigureVersionInfo.cmake)
334 # A set of directories to scan for calculating the hash of source files.
335 set(SET_OF_DIRECTORIES_TO_CHECKSUM "${PROJECT_SOURCE_DIR}/src")
336 list(APPEND SET_OF_DIRECTORIES_TO_CHECKSUM "${PROJECT_SOURCE_DIR}/python_packaging")
337 # Try to find python for the checksumming script
338 set(PythonInterp_FIND_QUIETLY ON)
339 find_package(PythonInterp 3.5)
341 # Rules to create the VersionInfo.cmake file.
342 # For git info, the sequence is:
343 # 1. (configure time) VersionInfo.cmake.cmakein -> VersionInfo-partial.cmake.cmakein
344 # - Set all variables that are known at configure time.
345 # 2. (build time) VersionInfo-partial.cmake.cmakein -> VersionInfo.cmake
346 # - Set variables that may change as result of repository state changes
347 # (i.e., everything that requires running git).
348 # - Runs every time as a git-version-info target, but the output file
349 # timestamp only changes if its contents actually change.
350 # - Depending on the native build system, this may run once per build
351 # or once per each time it is required for step 3.
352 # 3. (build time) VersionInfo.cmake -> other files
353 # - Set variables in files specified with gmx_configure_version_file()
354 # using the values generated in step 2.
355 # - Each file runs as a custom command that depends on the previous
356 # steps, and runs only if the VersionInfo.cmake file is newer than the
358 # Without git info, the sequence is:
359 # 1. (configure time) VersionInfo.cmake.cmakein -> VersionInfo.cmake
360 # - Everything is known at configure time, so the output is generated
361 # immediately with all variables set (git info will be empty).
362 # 2. (build time) VersionInfo.cmake -> other files
363 # - As with git info, processes files from gmx_configure_version_file().
364 # - These are again custom commands that depend on the output from
365 # step 1, so they get regenerated only when the static version info
367 if (GMX_GIT_VERSION_INFO)
368 # Configure information known at this time into a partially filled
370 set(VERSION_INFO_CMAKEIN_FILE_PARTIAL
371 ${PROJECT_BINARY_DIR}/VersionInfo-partial.cmake.cmakein)
372 # Leave these to be substituted by the custom target below.
373 set(GMX_VERSION_STRING_FULL "\@GMX_VERSION_STRING_FULL\@")
374 set(GMX_VERSION_FULL_HASH "\@GMX_VERSION_FULL_HASH\@")
375 set(GMX_VERSION_CENTRAL_BASE_HASH "\@GMX_VERSION_CENTRAL_BASE_HASH\@")
376 configure_file(${VERSION_INFO_CMAKEIN_FILE}
377 ${VERSION_INFO_CMAKEIN_FILE_PARTIAL}
379 # If generating the version info, create a target that runs on every build
380 # and does the actual git calls, storing the results into a CMake script.
381 # This needs to be run at build time to update the version information
382 # properly when the git hash changes, but the build system does not.
383 # All targets added by gmx_configure_version_file() use the information
384 # from this script to get their variables from, removing the need to run
385 # git multiple times and simplifying reuse for other purposes.
386 gmx_add_custom_output_target(git-version-info RUN_ALWAYS
387 OUTPUT ${VERSION_INFO_CMAKE_FILE}
388 COMMAND ${CMAKE_COMMAND}
389 -D GIT_EXECUTABLE=${GIT_EXECUTABLE}
390 -D PROJECT_VERSION=${GMX_VERSION_STRING}
391 -D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
392 -D VERSION_CMAKEIN=${VERSION_INFO_CMAKEIN_FILE_PARTIAL}
393 -D VERSION_OUT=${VERSION_INFO_CMAKE_FILE}
394 -P ${CMAKE_CURRENT_LIST_DIR}/gmxGenerateVersionInfo.cmake
395 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
396 COMMENT "Generating git version information")
397 list(APPEND VERSION_INFO_DEPS git-version-info)
399 # If the version info is static, just generate the CMake script with the
400 # version variables during the CMake run.
401 set(GMX_VERSION_STRING_FULL ${GMX_VERSION_STRING})
402 set(GMX_VERSION_FULL_HASH "")
403 set(GMX_VERSION_CENTRAL_BASE_HASH "")
404 # To notify the user during compilation and at runtime that the build source
405 # has not been modified after unpacking the source tarball, the contents are hashed
406 # to be compared to a hash computed during the release process. If the hash matches
407 # all is fine and the user gets a message in the log file indicating that.
408 # If either the release hash file is missing, or if the hash does not match
409 # a different message is printed to indicate that the source has been changed
410 # compared to the version actually released. This is not needed in case a build
411 # is done in git, as we have the information there already.
412 # This is not done if the user has explicitly set an additional custom version string with
413 # -DGMX_VERSION_STRING_OF_FORK, as this indicates that they are knowing that a custom
414 # version of GROMACS is in use.
415 set(RELEASE_CHECKSUM_FILE "${PROJECT_SOURCE_DIR}/src/reference_checksum")
416 if(NOT GMX_VERSION_STRING_OF_FORK OR "${GMX_VERSION_STRING_OF_FORK}" STREQUAL "")
417 if(EXISTS ${RELEASE_CHECKSUM_FILE} AND PythonInterp_FOUND)
418 file(READ ${RELEASE_CHECKSUM_FILE} GMX_RELEASE_SOURCE_FILE_CHECKSUM)
419 string(STRIP ${GMX_RELEASE_SOURCE_FILE_CHECKSUM} GMX_RELEASE_SOURCE_FILE_CHECKSUM)
420 set(CHECKSUM_RESULT_FILE "${CMAKE_CURRENT_BINARY_DIR}/computed_checksum")
421 execute_process(COMMAND ${PYTHON_EXECUTABLE}
422 ${PROJECT_SOURCE_DIR}/admin/createFileHash.py
423 -s ${SET_OF_DIRECTORIES_TO_CHECKSUM}
424 -o ${CHECKSUM_RESULT_FILE}
425 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
427 file(READ ${CHECKSUM_RESULT_FILE} GMX_CURRENT_SOURCE_FILE_CHECKSUM)
428 string(STRIP ${GMX_CURRENT_SOURCE_FILE_CHECKSUM} GMX_CURRENT_SOURCE_FILE_CHECKSUM)
429 if(NOT ${GMX_RELEASE_SOURCE_FILE_CHECKSUM} STREQUAL ${GMX_CURRENT_SOURCE_FILE_CHECKSUM})
430 set(GMX_VERSION_STRING_FULL "${GMX_VERSION_STRING_FULL}-MODIFIED")
431 message(STATUS "The source code for this GROMACS installation is different from the officially released version.")
433 elseif(PythonInterp_FOUND)
434 set(GMX_VERSION_STRING_FULL "${GMX_VERSION_STRING_FULL}-UNCHECKED")
435 set(GMX_RELEASE_SOURCE_FILE_CHECKSUM "NoChecksumFile")
436 set(GMX_CURRENT_SOURCE_FILE_CHECKSUM "NoChecksumFile")
437 message(WARNING "Could not valdiate the GROMACS source due to missing reference checksum file.")
439 set(GMX_VERSION_STRING_FULL "${GMX_VERSION_STRING_FULL}-UNCHECKED")
440 set(GMX_RELEASE_SOURCE_FILE_CHECKSUM "NoPythonAvailable")
441 set(GMX_CURRENT_SOURCE_FILE_CHECKSUM "NoPythonAvailable")
442 message(STATUS "Could not calculate checksum of source files without Python")
445 configure_file(${VERSION_INFO_CMAKEIN_FILE} ${VERSION_INFO_CMAKE_FILE})
447 unset(GMX_VERSION_STRING_FULL)
448 unset(GMX_VERSION_FULL_HASH)
449 unset(GMX_VERSION_CENTRAL_BASE_HASH)
450 unset(GMX_RELEASE_SOURCE_FILE_CHECKSUM)
451 unset(GMX_CURRENT_SOURCE_FILE_CHECKSUM)
454 # What file the checksum should be written to
455 set(CHECKSUM_FILE "${PROJECT_SOURCE_DIR}/src/reference_checksum")
457 # Target that allows checksumming a source tree when producing a tarball.
458 # Allows verification of builds from the tarball to make sure the source had
459 # not been tampered with.
460 # Note: The RUN_ALWAYS here is to regenerate the hash file only, it does not
461 # mean that the target is run in all builds
462 if (PYTHONINTERP_FOUND)
463 gmx_add_custom_output_target(reference_checksum RUN_ALWAYS
464 OUTPUT ${CHECKSUM_FILE}
465 COMMAND ${PYTHON_EXECUTABLE}
466 ${PROJECT_SOURCE_DIR}/admin/createFileHash.py
467 -s ${SET_OF_DIRECTORIES_TO_CHECKSUM}
469 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
470 COMMENT "Generating reference checksum of source files")
472 add_custom_target(reference_checksum
473 COMMAND ${CMAKE_COMMAND} -E echo
474 "Can not checksum files without python being available"
475 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
476 COMMENT "Generating reference checksum of source files")
479 # The main user-visible interface to the machinery.
480 # See documentation at the top of the script.
481 function (gmx_configure_version_file INFILE OUTFILE)
482 include(CMakeParseArguments)
483 set(_options REMOTE_HASH)
484 set(_one_value_args COMMENT TARGET)
485 set(_multi_value_args EXTRA_VARS)
486 cmake_parse_arguments(
487 ARG "${_options}" "${_one_value_args}" "${_multi_value_args}" ${ARGN})
488 if (ARG_UNPARSED_ARGUMENTS)
489 message(FATAL_ERROR "Unknown arguments: ${ARG_UNPARSED_ARGUMENTS}")
491 # Some callers may pass partial paths that do not really make sense,
492 # so create a default comment that only contains the actual file name.
493 get_filename_component(_basename ${OUTFILE} NAME)
494 set(_comment "Generating ${_basename}")
496 set(_comment ${ARG_COMMENT})
498 # Mimic configure_file()
499 if (NOT IS_ABSOLUTE ${INFILE})
500 set(INFILE ${CMAKE_CURRENT_SOURCE_DIR}/${INFILE})
502 # Create command-line definitions for the requested variables
503 set(_extra_var_defines)
504 foreach(_var ${ARG_EXTRA_VARS})
505 list(APPEND _extra_var_defines -D "${_var}=${${_var}}")
507 # The touch command is necessary to ensure that after the target is run,
508 # the timestamp is newer than in the input files.
509 add_custom_command(OUTPUT ${OUTFILE}
510 COMMAND ${CMAKE_COMMAND}
511 -D VERSION_VARIABLES=${VERSION_INFO_CMAKE_FILE}
512 -D VERSION_CMAKEIN=${INFILE}
513 -D VERSION_OUT=${OUTFILE}
514 ${_extra_var_defines}
515 -P ${VERSION_INFO_CONFIGURE_SCRIPT}
516 COMMAND ${CMAKE_COMMAND} -E touch ${OUTFILE}
517 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
518 DEPENDS ${INFILE} ${VERSION_INFO_DEPS} ${VERSION_INFO_CONFIGURE_SCRIPT}
519 COMMENT "${_comment}"
522 add_custom_target(${ARG_TARGET} DEPENDS ${OUTFILE} VERBATIM)
523 gmx_set_custom_target_output(${ARG_TARGET} ${OUTFILE})