gnucash/cmake/configure-totd.cmake
Geert Janssens 5bf3bfc6b6 Bug 797691 - Tip of the day is not rebuilt when the source file changes
Changes to tip_of_the_day.list.c will now properly trigger a rebuild.

Plus a few minor assorted fixes and changes to generating the man pages
- only generate the final files in share/gnucash, not in the build directory
- gnucash-cli.1 was not installed, gnucash.1 twice
2021-03-17 16:24:22 +01:00

25 lines
1001 B
CMake

# Command to configure the gnucash man page
# These commands are store in a separate cmake file as they have to be
# rerun depending on build conditions, not depending on cmake conditions
# (such as did the version string change or not)
#
# The following environment variables are used and should be properly set
# by the calling code:
# - SRC_DIR (source code directory containing tip_of_the_day.list.c)
# - DST_DIR (build dir to write tip_of_the_day.list to)
# - SRC (full path to tip_of_the_day.list.c)
# - DST (target filename)
# - CMAKE_C_COMPILER (path to C compiler, used to parse the input file)
file(REMOVE ${DST_DIR}/${TOTD})
execute_process(
COMMAND ${CMAKE_C_COMPILER} -E -P -x c -DN_\(x\)=x -o ${TOTD}.tmp ${SRC}
)
file(STRINGS ${TOTD}.tmp TIP_OF_THE_DAY_LINES)
set(TOTD_OUTPUT "")
foreach(line ${TIP_OF_THE_DAY_LINES})
string(REGEX REPLACE "^ *\"" "" line2 "${line}")
string(REGEX REPLACE "\" *$" "" line3 "${line2}")
file(APPEND ${DST_DIR}/${TOTD} "${line3}\n")
endforeach()