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
61 # LIBRARY_SOVERSION_MINOR so minor version for the built libraries.
62 # Should be increased for each release that changes only the implementation.
63 # In GROMACS, the typical policy is to increase it for each patch version
64 # change, even if they may not always be fully binary compatible.
65 # If it is somehow clear that the ABI implementation has not changed
66 # in a patch release, this variable should not increase. Release candidate
67 # and beta versions will not increase this number, since nobody should
68 # write code against such versions.
69 # LIBRARY_VERSION Full library version.
70 # REGRESSIONTEST_BRANCH For builds not from source packages, name of the
71 # regressiontests branch at gerrit.gromacs.org whose HEAD can test this
72 # code, *if* this code is recent enough (i.e., contains all changes from
73 # the corresponding code branch that affects the regression test
74 # results). Even after a release branch is forked for the source
75 # repository, the correct regressiontests branch can still be master,
76 # because we do not fork it until behaviour needs to change.
77 # REGRESSIONTEST_MD5SUM
78 # The MD5 checksum of the regressiontest tarball. Only used when building
79 # from a source package.
81 # ID collected from Zenodo connected to the doi for a released version
82 # used to identify the source when building an official released version.
83 # This ID is used for the source code tarball.
85 # Same as above, but for the reference manual.
86 # They are collected into a single section below.
87 # The following variables are set based on these:
88 # GMX_VERSION String composed from GMX_VERSION_* numeric variables
89 # above. Example: 4.6.1, 5.0, 2016
90 # GMX_VERSION_STRING String with GMX_VERSION suffixed with the given
91 # suffix and possibly "-dev" for builds not from a source package.
92 # GMX_VERSION_NUMERIC Numeric version number (e.g., 40601 for 4.6.1, 20160001 for 2016.1).
93 # GMX_API_VERSION Numeric API version.
94 # This is currently set automatically to GMX_VERSION_NUMERIC, but may
95 # become manually maintained in the future if there will be releases
96 # where the API does not change, but programs/libraries do.
97 # In such a case, this should be the first version where the current API
99 # REGRESSIONTEST_VERSION For source packages, version number of the
100 # matching regressiontests tarball. Not used for builds not from source
102 # The latter two are used to generate gromacs/version.h to allow software
103 # written against the GROMACS API to provide some #ifdef'ed code to support
104 # multiple GROMACS versions.
106 # This script also declares machinery to generate and obtain version
107 # information from a git repository. This is enabled by default if the source
108 # tree is a git, but can be disabled with
109 # GMX_GIT_VERSION_INFO Advanced CMake variable to disable git
110 # version info generation.
111 # If the version generation is disabled, then the source and manual doi
112 # will be based on the stored values for the ID.
113 # The main interface to this machinery is the gmx_configure_version_file()
114 # CMake function. The signature is
115 # gmx_configure_version_file(<input> <output>
118 # [COMMENT <comment>])
119 # <input> Specify the input and output files as for configure_file().
120 # <output> The configuration is done with configure_file(... @ONLY) with
121 # the following variables defined (as well as all the
122 # GMX_VERSION* variables from above):
123 # GMX_VERSION_STRING_FULL
124 # GMX_VERSION_FULL_HASH
125 # GMX_VERSION_CENTRAL_BASE_HASH
126 # The output file is created during build time, so any dependent
127 # targets should specify it as a dependency.
128 # REMOTE_HASH Currently, this has no effect, but it signifies that the
129 # <input> file is using the CENTRAL_BASE_HASH variable.
130 # This variable is much more expensive to initialize than the
131 # others, so this allows local changes in this file to only
132 # compute that value when required if that becomes necessary.
133 # TARGET By default, this function uses add_custom_command() to
134 # generate the output file. If TARGET is specified, then
135 # add_custom_target() is used to create a target with the given
136 # name <target> that runs this custom command. Use this if
137 # the same file will be used for multiple downstream targets,
138 # or if the explicit target for the file is otherwise
140 # COMMENT Set a custom comment to be shown when building the rule
141 # (see add_custom_command(... COMMENT <comment>)).
142 # As an alternative to using this script, also the following variables are
143 # provided (can be useful when generating more complex CMake scripts that do
145 # VERSION_INFO_CMAKE_SCRIPT
146 # Absolute path to a CMake script that can be included using include()
147 # to declare the GMX_VERSION_* variables documented for
148 # gmx_configure_version_file().
150 # If a custom command depends on VERSION_INFO_CMAKE_SCRIPT, then it
151 # should add ${VERSION_INFO_DEPS} to its DEPENDS list to get the
152 # appropriate dependencies.
153 # TODO: If someone wants to add a custom target that depends on
154 # VERSION_INFO_CMAKE_SCRIPT, a separate variable may be needed for those
157 # The version string printed by 'gmx -version' (and also printed in the startup
158 # header) can provide useful information for, e.g., diagnosing bug reports and
159 # identifying what exact version the user was using. The following formats are
160 # possible (with examples given for a particular version):
161 # 2018.1 Plain version number without any suffix signifies a build from
162 # a released source tarball.
163 # 2018.1-dev '-dev' suffix signifies all other builds. If there is no other
164 # information, either the user built the code outside any git
165 # repository, or disabled the version info generation.
166 # 2018.1-dev-YYYYMMDD-1234abc
167 # The YYYYMMDD part shows the commit date (not author date) of
168 # the HEAD commit from which the code was built. The abbreviated
169 # hash is the hash of that commit (the full hash is available in
170 # 'gmx -version' output).
171 # If the HEAD hash is not identified as coming from branches in
172 # "authoritative" GROMACS repositories, 'gmx -version' will show
173 # the nearest ancestor commit that is identified as such (but see
174 # the '-local' and '-unknown' suffixes below).
175 # 2018.1-dev-YYYYMMDD-1234abc-dirty
176 # As above, but there were local modifications in the source tree
177 # when the code was built.
178 # 2018.1-dev-YYYYMMDD-1234abc-unknown
179 # As above, but there were no remotes in the repository that
180 # could be identified as "authoritative" GROMACS repositories.
181 # This happens if the code is not cloned from git.gromacs.org
182 # or gerrit.gromacs.org.
183 # 2018.1-dev-YYYYMMDD-1234abc-local
184 # As above, but there were no commits in the recent history of
185 # the branch that could be identified as coming from
186 # "authoritative" GROMACS repositories. This should be
189 # Other variables set here are not intended for use outside this file.
190 # The scripts gmxGenerateVersionInfo.cmake and gmxConfigureVersionInfo.cmake
191 # are used internally by this machinery, as well as VersionInfo.cmake.cmakein.
193 #####################################################################
194 # Manually maintained version info
196 # The GROMACS convention is that these are the version number of the next
197 # release that is going to be made from this branch.
198 set(GMX_VERSION_MAJOR 2020)
199 set(GMX_VERSION_PATCH 2)
200 # The suffix, on the other hand, is used mainly for betas and release
201 # candidates, where it signifies the most recent such release from
202 # this branch; it will be empty before the first such release, as well
203 # as after the final release is out.
204 set(GMX_VERSION_SUFFIX "")
206 # Conventionally with libtool, any ABI change must change the major
207 # version number, the minor version number should change if it's just
208 # the implementation that has been altered, and the third number
209 # counts the number of old major versions that will still run if
210 # linked to this library (i.e. it is not a patch number). See the
211 # above descriptions of LIBRARY_SOVERSION_* for policy for changes
212 # here. The important thing is to minimize the chance of third-party
213 # code being able to dynamically link with a version of libgromacs
214 # that might not work.
215 set(LIBRARY_SOVERSION_MAJOR 5)
216 set(LIBRARY_SOVERSION_MINOR 0)
217 set(LIBRARY_VERSION ${LIBRARY_SOVERSION_MAJOR}.${LIBRARY_SOVERSION_MINOR}.0)
219 #####################################################################
220 # General version management based on manually set numbers
222 if (GMX_VERSION_PATCH)
223 set(GMX_VERSION "${GMX_VERSION_MAJOR}.${GMX_VERSION_PATCH}")
225 set(GMX_VERSION "${GMX_VERSION_MAJOR}")
227 set(GMX_VERSION_STRING "${GMX_VERSION}${GMX_VERSION_SUFFIX}")
229 # If you are making a custom fork of GROMACS, please describe your
230 # fork, perhaps with its version number, in the value of
231 # GMX_VERSION_STRING_OF_FORK here. This string will appear in the
232 # header of log files that mdrun writes. This will help you, your
233 # users, your system administrators, your maintainers and the
234 # maintainers of GROMACS core understand how to troubleshoot and
235 # reproduce potential problems.
237 # If you are distributing a patch to GROMACS, then this change would
238 # be great as part of your patch. Otherwise for personal use, you can
239 # also just set a CMake cache variable.
240 set(GMX_VERSION_STRING_OF_FORK "" CACHE INTERNAL
241 "Version string for forks of GROMACS to set to describe themselves")
242 mark_as_advanced(GMX_VERSION_STRING_OF_FORK)
243 if (GMX_VERSION_STRING_OF_FORK)
244 set(GMX_VERSION_STRING "${GMX_VERSION_STRING}-${GMX_VERSION_STRING_OF_FORK}")
247 option(GMX_BUILD_TARBALL "Build tarball without -dev version suffix" OFF)
248 mark_as_advanced(GMX_BUILD_TARBALL)
249 # If run with cmake -P, the -dev suffix is managed elsewhere.
250 if (NOT SOURCE_IS_SOURCE_DISTRIBUTION AND
251 NOT GMX_BUILD_TARBALL AND
252 NOT CMAKE_SCRIPT_MODE_FILE)
253 set(GMX_VERSION_STRING "${GMX_VERSION_STRING}-dev")
256 set(REGRESSIONTEST_VERSION "${GMX_VERSION_STRING}")
257 set(REGRESSIONTEST_BRANCH "release-2020")
258 # Run the regressiontests packaging job with the correct pakage
259 # version string, and the release box checked, in order to have it
260 # build the regressiontests tarball with all the right naming. The
261 # naming affects the md5sum that has to go here, and if it isn't right
262 # release workflow will report a failure.
263 set(REGRESSIONTEST_MD5SUM "b75c3b1bac0e4114e236f049fc7f1f1c" CACHE INTERNAL "MD5 sum of the regressiontests tarball for this GROMACS version")
265 math(EXPR GMX_VERSION_NUMERIC
266 "${GMX_VERSION_MAJOR}*10000 + ${GMX_VERSION_PATCH}")
267 set(GMX_API_VERSION ${GMX_VERSION_NUMERIC})
269 # If run with cmake -P from releng scripts, print out necessary version info
271 if (CMAKE_SCRIPT_MODE_FILE)
272 message("{ \"version\": \"${GMX_VERSION_STRING}\", \"regressiontest-md5sum\": \"${REGRESSIONTEST_MD5SUM}\" }")
276 # Set those values only in release versions, after getting the identifiers
277 # from Zenodo for the manual and source code
278 # Has to be done by hand before every final release
279 # Use force to override anything given as a cmake command line input
280 # Actual input depends on the GMX_VERSION_STRING_OF_FORK variable being set or not.
281 # If it is set, we always default to an empty string, otherwise to the value set for the release build.
282 if (GMX_VERSION_STRING_OF_FORK)
283 set(GMX_MANUAL_DOI_INTERNAL "")
284 set(GMX_SOURCE_DOI_INTERNAL "")
286 set(GMX_MANUAL_DOI_INTERNAL "10.5281/zenodo.3773799") # Set correct doi string here
287 set(GMX_SOURCE_DOI_INTERNAL "10.5281/zenodo.3773801") # Set correct doi string here
289 set(GMX_MANUAL_DOI ${GMX_MANUAL_DOI_INTERNAL} CACHE INTERNAL "reserved doi for GROMACS manual" FORCE)
290 set(GMX_SOURCE_DOI ${GMX_SOURCE_DOI_INTERNAL} CACHE INTERNAL "reserved doi for GROMACS source code" FORCE)
292 #####################################################################
293 # git version info management
295 # There can be clusters where git and CMake can run on nodes where the other is
296 # not available, accessing the same source tree.
297 # Should be unlikely, but doesn't hurt to check.
298 set(_git_info_default OFF)
299 if (SOURCE_IS_GIT_REPOSITORY)
302 set(_git_info_default ON)
305 option(GMX_GIT_VERSION_INFO "Generate git version information" ${_git_info_default})
306 mark_as_advanced(GMX_GIT_VERSION_INFO)
307 # Detect preconditions for version info generation if it is requested.
308 if (GMX_GIT_VERSION_INFO)
309 if (NOT SOURCE_IS_GIT_REPOSITORY)
311 "Cannot generate git version information from source tree not under git. "
312 "Set GMX_GIT_VERSION_INFO=OFF to proceed.")
314 # We need at least git v1.5.3 be able to parse git's date output.
315 if (NOT GIT_FOUND OR GIT_VERSION_STRING VERSION_LESS "1.5.3")
317 "No compatible git version found (>= 1.5.3 required). "
318 "Won't be able to generate development version information. "
319 "Set GMX_GIT_VERSION_INFO=OFF to proceed.")
323 include(gmxCustomCommandUtilities)
325 # The first two are also for use outside this file, encapsulating the details
326 # of how to use the generated VersionInfo.cmake.
327 set(VERSION_INFO_CMAKE_FILE ${PROJECT_BINARY_DIR}/VersionInfo.cmake)
328 set(VERSION_INFO_DEPS ${VERSION_INFO_CMAKE_FILE})
329 # Capture the location of the necessary files in internal variables for use in
330 # the function below.
331 set(VERSION_INFO_CMAKEIN_FILE ${CMAKE_CURRENT_LIST_DIR}/VersionInfo.cmake.cmakein)
332 set(VERSION_INFO_CONFIGURE_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/gmxConfigureVersionInfo.cmake)
333 # A set of directories to scan for calculating the hash of source files.
334 set(SET_OF_DIRECTORIES_TO_CHECKSUM "src")
335 list(APPEND SET_OF_DIRECTORIES_TO_CHECKSUM "python_packaging")
336 # Due to the limitations for passing a list as arguments, we make the directories a string here
337 string(REPLACE ";" ":" DIRECTORIES_TO_CHECKSUM_STRING "${SET_OF_DIRECTORIES_TO_CHECKSUM}")
338 # Try to find python for the checksumming script
339 set(PythonInterp_FIND_QUIETLY ON)
340 find_package(PythonInterp 3.5)
342 # Rules to create the VersionInfo.cmake file.
343 # For git info, the sequence is:
344 # 1. (configure time) VersionInfo.cmake.cmakein -> VersionInfo-partial.cmake.cmakein
345 # - Set all variables that are known at configure time.
346 # 2. (build time) VersionInfo-partial.cmake.cmakein -> VersionInfo.cmake
347 # - Set variables that may change as result of repository state changes
348 # (i.e., everything that requires running git).
349 # - Runs every time as a git-version-info target, but the output file
350 # timestamp only changes if its contents actually change.
351 # - Depending on the native build system, this may run once per build
352 # or once per each time it is required for step 3.
353 # 3. (build time) VersionInfo.cmake -> other files
354 # - Set variables in files specified with gmx_configure_version_file()
355 # using the values generated in step 2.
356 # - Each file runs as a custom command that depends on the previous
357 # steps, and runs only if the VersionInfo.cmake file is newer than the
359 # Without git info, the sequence is:
360 # 1. (configure time) VersionInfo.cmake.cmakein -> VersionInfo.cmake
361 # - Everything is known at configure time, so the output is generated
362 # immediately with all variables set (git info will be empty).
363 # 2. (build time) VersionInfo.cmake -> other files
364 # - As with git info, processes files from gmx_configure_version_file().
365 # - These are again custom commands that depend on the output from
366 # step 1, so they get regenerated only when the static version info
369 # Configure information known at this time into a partially filled
371 set(VERSION_INFO_CMAKEIN_FILE_PARTIAL
372 ${PROJECT_BINARY_DIR}/VersionInfo-partial.cmake.cmakein)
373 # Leave these to be substituted by the targets below.
374 set(GMX_VERSION_STRING_FULL "\@GMX_VERSION_STRING_FULL\@")
376 if (GMX_GIT_VERSION_INFO)
377 # Leave these to be substituted by the custom target below.
378 # Specific for building from git.
379 set(GMX_VERSION_FULL_HASH "\@GMX_VERSION_FULL_HASH\@")
380 set(GMX_VERSION_CENTRAL_BASE_HASH "\@GMX_VERSION_CENTRAL_BASE_HASH\@")
381 # If generating the version info, create a target that runs on every build
382 # and does the actual git calls, storing the results into a CMake script.
383 # This needs to be run at build time to update the version information
384 # properly when the git hash changes, but the build system does not.
385 # All targets added by gmx_configure_version_file() use the information
386 # from this script to get their variables from, removing the need to run
387 # git multiple times and simplifying reuse for other purposes.
388 gmx_add_custom_output_target(git-version-info RUN_ALWAYS
389 OUTPUT ${VERSION_INFO_CMAKE_FILE}
390 COMMAND ${CMAKE_COMMAND}
391 -D GIT_EXECUTABLE=${GIT_EXECUTABLE}
392 -D PROJECT_VERSION=${GMX_VERSION_STRING}
393 -D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
394 -D VERSION_CMAKEIN=${VERSION_INFO_CMAKEIN_FILE_PARTIAL}
395 -D VERSION_OUT=${VERSION_INFO_CMAKE_FILE}
396 -P ${CMAKE_CURRENT_LIST_DIR}/gmxGenerateVersionInfo.cmake
397 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
398 COMMENT "Generating git version information")
399 list(APPEND VERSION_INFO_DEPS git-version-info)
401 # Leave these to be substituted by the custom target below.
402 # Specific for building from source tarball.
403 set(GMX_RELEASE_SOURCE_FILE_CHECKSUM "\@GMX_RELEASE_SOURCE_FILE_CHECKSUM\@")
404 set(GMX_CURRENT_SOURCE_FILE_CHECKSUM "\@GMX_CURRENT_SOURCE_FILE_CHECKSUM\@")
405 gmx_add_custom_output_target(release-version-info RUN_ALWAYS
406 OUTPUT ${VERSION_INFO_CMAKE_FILE}
407 COMMAND ${CMAKE_COMMAND}
408 -D PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
409 -D PROJECT_VERSION=${GMX_VERSION_STRING}
410 -D PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
411 -D DIRECTORIES_TO_CHECKSUM=${DIRECTORIES_TO_CHECKSUM_STRING}
412 -D VERSION_CMAKEIN=${VERSION_INFO_CMAKEIN_FILE_PARTIAL}
413 -D VERSION_OUT=${VERSION_INFO_CMAKE_FILE}
414 -D VERSION_STRING_OF_FORK=${GMX_VERSION_STRING_OF_FORK}
415 -P ${CMAKE_CURRENT_LIST_DIR}/gmxGenerateVersionInfoRelease.cmake
416 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
417 COMMENT "Generating release version information")
418 list(APPEND VERSION_INFO_DEPS release-version-info)
420 configure_file(${VERSION_INFO_CMAKEIN_FILE}
421 ${VERSION_INFO_CMAKEIN_FILE_PARTIAL}
423 unset(GMX_VERSION_STRING_FULL)
424 unset(GMX_VERSION_FULL_HASH)
425 unset(GMX_VERSION_CENTRAL_BASE_HASH)
426 unset(GMX_RELEASE_SOURCE_FILE_CHECKSUM)
427 unset(GMX_CURRENT_SOURCE_FILE_CHECKSUM)
430 # What file the checksum should be written to
431 set(CHECKSUM_FILE "${PROJECT_SOURCE_DIR}/src/reference_checksum")
433 # Target that allows checksumming a source tree when producing a tarball.
434 # Allows verification of builds from the tarball to make sure the source had
435 # not been tampered with.
436 # Note: The RUN_ALWAYS here is to regenerate the hash file only, it does not
437 # mean that the target is run in all builds
438 if (PYTHONINTERP_FOUND)
439 # We need the full path to the directories after passing it through
440 set(FULL_PATH_DIRECTORIES "")
441 foreach(DIR ${SET_OF_DIRECTORIES_TO_CHECKSUM})
442 list(APPEND FULL_PATH_DIRECTORIES "${PROJECT_SOURCE_DIR}/${DIR}")
444 gmx_add_custom_output_target(reference_checksum RUN_ALWAYS
445 OUTPUT ${CHECKSUM_FILE}
446 COMMAND ${PYTHON_EXECUTABLE}
447 ${PROJECT_SOURCE_DIR}/admin/createFileHash.py
448 -s ${FULL_PATH_DIRECTORIES}
450 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
451 COMMENT "Generating reference checksum of source files")
453 add_custom_target(reference_checksum
454 COMMAND ${CMAKE_COMMAND} -E echo
455 "Can not checksum files without python being available"
456 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
457 COMMENT "Generating reference checksum of source files")
460 # The main user-visible interface to the machinery.
461 # See documentation at the top of the script.
462 function (gmx_configure_version_file INFILE OUTFILE)
463 include(CMakeParseArguments)
464 set(_options REMOTE_HASH)
465 set(_one_value_args COMMENT TARGET)
466 set(_multi_value_args EXTRA_VARS)
467 cmake_parse_arguments(
468 ARG "${_options}" "${_one_value_args}" "${_multi_value_args}" ${ARGN})
469 if (ARG_UNPARSED_ARGUMENTS)
470 message(FATAL_ERROR "Unknown arguments: ${ARG_UNPARSED_ARGUMENTS}")
472 # Some callers may pass partial paths that do not really make sense,
473 # so create a default comment that only contains the actual file name.
474 get_filename_component(_basename ${OUTFILE} NAME)
475 set(_comment "Generating ${_basename}")
477 set(_comment ${ARG_COMMENT})
479 # Mimic configure_file()
480 if (NOT IS_ABSOLUTE ${INFILE})
481 set(INFILE ${CMAKE_CURRENT_SOURCE_DIR}/${INFILE})
483 # Create command-line definitions for the requested variables
484 set(_extra_var_defines)
485 foreach(_var ${ARG_EXTRA_VARS})
486 list(APPEND _extra_var_defines -D "${_var}=${${_var}}")
488 # The touch command is necessary to ensure that after the target is run,
489 # the timestamp is newer than in the input files.
490 add_custom_command(OUTPUT ${OUTFILE}
491 COMMAND ${CMAKE_COMMAND}
492 -D VERSION_VARIABLES=${VERSION_INFO_CMAKE_FILE}
493 -D VERSION_CMAKEIN=${INFILE}
494 -D VERSION_OUT=${OUTFILE}
495 ${_extra_var_defines}
496 -P ${VERSION_INFO_CONFIGURE_SCRIPT}
497 COMMAND ${CMAKE_COMMAND} -E touch ${OUTFILE}
498 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
499 DEPENDS ${INFILE} ${VERSION_INFO_DEPS} ${VERSION_INFO_CONFIGURE_SCRIPT}
500 COMMENT "${_comment}"
503 add_custom_target(${ARG_TARGET} DEPENDS ${OUTFILE} VERBATIM)
504 gmx_set_custom_target_output(${ARG_TARGET} ${OUTFILE})