From 5bf3bfc6b6edf69da4138abe6c38eafa5c20a215 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 17 Mar 2021 16:19:07 +0100 Subject: [PATCH] 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 --- cmake/CMakeLists.txt | 2 +- cmake/configure-manpage.cmake | 3 +- cmake/configure-totd.cmake | 24 ++++++++++++++++ doc/CMakeLists.txt | 53 ++++++++++++++++------------------- gnucash/CMakeLists.txt | 2 -- 5 files changed, 50 insertions(+), 34 deletions(-) create mode 100644 cmake/configure-totd.cmake diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c8aa8da9f6..3d460e2f79 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -10,5 +10,5 @@ endif() set_dist_list(cmake_DIST CMakeLists.txt README_CMAKE.txt cmake_uninstall.cmake.in configure-appdata.cmake configure-gnucash-desktop.cmake configure-manpage.cmake - git2version-info.cmake version-info2env.cmake + configure-totd.cmake git2version-info.cmake version-info2env.cmake ) diff --git a/cmake/configure-manpage.cmake b/cmake/configure-manpage.cmake index 9e1a21c519..fe09f265d9 100644 --- a/cmake/configure-manpage.cmake +++ b/cmake/configure-manpage.cmake @@ -12,5 +12,4 @@ include (${SRC_DIR}/cmake/version-info2env.cmake) versioninfo2env (${VCS_INFO_FILE}) -configure_file(${SRC} ${DST} ) -configure_file(${DST} ${DATADIR_BUILD}/gnucash/${DST} COPYONLY) +configure_file(${SRC} ${DATADIR_BUILD}/gnucash/${DST} ) diff --git a/cmake/configure-totd.cmake b/cmake/configure-totd.cmake new file mode 100644 index 0000000000..f4906c4dfa --- /dev/null +++ b/cmake/configure-totd.cmake @@ -0,0 +1,24 @@ +# 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() diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index b7e83f1238..91104cdf14 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -19,40 +19,35 @@ endforeach() # Generate the tip of the day file. -execute_process( - COMMAND ${CMAKE_C_COMPILER} -E -P -x c -DN_\(x\)=x -o ${CMAKE_CURRENT_BINARY_DIR}/tip_of_the_day.list.tmp ${CMAKE_CURRENT_SOURCE_DIR}/tip_of_the_day.list.c +set (totd "tip_of_the_day.list") +add_custom_command(OUTPUT ${DATADIR_BUILD}/gnucash/${totd} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${totd}.c + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} + -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/${totd}.c + -D TOTD=${totd} + -D DST_DIR=${DATADIR_BUILD}/gnucash + -D CMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -P ${CMAKE_SOURCE_DIR}/cmake/configure-totd.cmake ) +add_custom_target(totd ALL DEPENDS ${DATADIR_BUILD}/gnucash/${totd}) -file(STRINGS ${CMAKE_CURRENT_BINARY_DIR}/tip_of_the_day.list.tmp TIP_OF_THE_DAY_LINES) +install(FILES ${DATADIR_BUILD}/gnucash/tip_of_the_day.list DESTINATION ${CMAKE_INSTALL_DATADIR}/gnucash) -set(TOTD_OUTPUT "") -foreach(line ${TIP_OF_THE_DAY_LINES}) - string(REGEX REPLACE "^ *\"" "" line2 "${line}") - string(REGEX REPLACE "\" *$" "" line3 "${line2}") - list(APPEND TOTD_OUTPUT "${line3}\n") -endforeach() - -string(CONCAT FINAL_TOTD ${TOTD_OUTPUT}) - -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tip_of_the_day.list "${FINAL_TOTD}") - -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tip_of_the_day.list DESTINATION ${CMAKE_INSTALL_DATADIR}/gnucash) - -file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tip_of_the_day.list - DESTINATION ${DATADIR_BUILD}/gnucash) +# Generate manpages. foreach (manpage gnucash gnucash-cli) - add_custom_command(OUTPUT ${manpage}.1 - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1.in ${VCS_INFO_FILE} - COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1.in - -D DST=${manpage}.1 - -D VCS_INFO_FILE=${VCS_INFO_FILE} - -D DATADIR_BUILD=${DATADIR_BUILD} - -D SRC_DIR=${CMAKE_SOURCE_DIR} - -P ${CMAKE_SOURCE_DIR}/cmake/configure-manpage.cmake + add_custom_command(OUTPUT ${DATADIR_BUILD}/gnucash/${manpage}.1 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1.in ${VCS_INFO_FILE} + COMMAND ${CMAKE_COMMAND} + -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1.in + -D DST=${manpage}.1 + -D VCS_INFO_FILE=${VCS_INFO_FILE} + -D DATADIR_BUILD=${DATADIR_BUILD} + -D SRC_DIR=${CMAKE_SOURCE_DIR} + -P ${CMAKE_SOURCE_DIR}/cmake/configure-manpage.cmake ) - add_custom_target(${manpage}-manpage DEPENDS ${manpage}.1) - dist_add_generated (${BUILDING_FROM_VCS} ${manpage}.1) + add_custom_target(${manpage}-manpage ALL DEPENDS ${DATADIR_BUILD}/gnucash/${manpage}.1) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) + install(FILES ${DATADIR_BUILD}/gnucash/${manpage}.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) endforeach() diff --git a/gnucash/CMakeLists.txt b/gnucash/CMakeLists.txt index bc2ab97cdf..1b52dd1f5f 100644 --- a/gnucash/CMakeLists.txt +++ b/gnucash/CMakeLists.txt @@ -53,8 +53,6 @@ add_executable (gnucash ${gnucash_noinst_HEADERS} ) -add_dependencies (gnucash gnucash-manpage gnucash-cli-manpage) - target_compile_definitions(gnucash PRIVATE -DG_LOG_DOMAIN=\"gnc.bin\") target_link_libraries (gnucash