gnucash/cmake/git2version-info.cmake
Geert Janssens c4a21bc9d4 Extract a few cmake commands to dedicated files rather than generating them on the fly
This simplifies a number of escape sequences.

The generated file to configure the man page was split up a bit further:
- code that extracted the GNC_VCS_REV_Y_M from gnc-vcs-info.h was spun out
  into its own function that now sets all parameters in gnc-vcs-info.h
  as environment variables.
- this function is now invoked by configure-manpage.cmake to extract
  the date to insert into the manpage.
- the manpage in addition now shows the full date rather than only
  yyyy-mm. This is how man itself does it as well.
2019-08-24 17:05:03 +02:00

29 lines
932 B
CMake

# Create the gnc-vcs-info.h file starting from git.
# It currently sets four parameters
# - GNC_VCS_REV
# - GNC_VCS_REV_DATE
# - GNC_VCS_REV_YEAR
# - GNC_VCS_REV_Y_M
# The following environment variables are used and should be properly set
# by the calling code:
# - SHELL (should point at a bash shell or compatible)
# - SRC_DIR (top level source code directory)
# - SRC (full path to gnc-vcs-info.h.in)
# - DST (full path to destination for gnc-vcs-info.h)
execute_process(
COMMAND ${SHELL} "${SRC_DIR}/util/gnc-vcs-info" -r "${SRC_DIR}"
OUTPUT_VARIABLE GNC_VCS_REV
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND ${SHELL} "${SRC_DIR}/util/gnc-vcs-info" -d "${SRC_DIR}"
OUTPUT_VARIABLE GNC_VCS_REV_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(SUBSTRING ${GNC_VCS_REV_DATE} 0 4 GNC_VCS_REV_YEAR)
string(SUBSTRING ${GNC_VCS_REV_DATE} 0 7 GNC_VCS_REV_Y_M)
configure_file(${SRC} ${DST} @ONLY)