From 7dc59950a59debfd78a3386ff77a99dfbece7522 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sat, 24 Aug 2019 16:32:56 +0200 Subject: [PATCH] Bug 797353 - Add copyright and release info in appdata file This also means the appdata file now requires preprocessing to set this info automatically. --- CMakeLists.txt | 7 +++++++ cmake/CMakeLists.txt | 2 +- cmake/configure-appdata.cmake | 16 ++++++++++++++++ doc/CMakeLists.txt | 8 -------- gnucash/gnome/CMakeLists.txt | 15 +++++++++++---- gnucash/gnome/gnucash.appdata.xml.in | 5 +++++ libgnucash/core-utils/CMakeLists.txt | 12 +++++++++++- 7 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 cmake/configure-appdata.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c417bd1f82..d6ac0c334e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,7 +152,14 @@ if (GNC_VCS_INFO_RESULT EQUAL 0) if (NOT GIT_FOUND) message(SEND_ERROR "Looks like we're building from version control, but can't find git executable. Please set GIT_EXECUTABLE.") endif() + set(VCS_INFO_BASE_DIR ${CMAKE_BINARY_DIR}) +else() + set(VCS_INFO_BASE_DIR ${CMAKE_SOURCE_DIR}) endif() +# The location of gnc-vcs-info.h depends on whether we build from VCS or not +# And this file is needed in several other build rules, so we define its +# location once here. +set(VCS_INFO_FILE ${VCS_INFO_BASE_DIR}/libgnucash/core-utils/gnc-vcs-info.h) # Determine whether to generate the swig wrappers. # By default they will only be generated when building from a git worktree diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index deaebf2b1e..bb3ddf2bbd 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -9,6 +9,6 @@ endif(APPLE) set_dist_list(cmake_DIST CMakeLists.txt README_CMAKE.txt cmake_uninstall.cmake.in - configure-manpage.cmake git2version-info.cmake + configure-appdata.cmake configure-manpage.cmake git2version-info.cmake version-info2env.cmake ) diff --git a/cmake/configure-appdata.cmake b/cmake/configure-appdata.cmake new file mode 100644 index 0000000000..11cc7b7653 --- /dev/null +++ b/cmake/configure-appdata.cmake @@ -0,0 +1,16 @@ +# Command to configure the gnucash appdata file +# These commands are stored 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 (top level source code directory) +# - SRC (full path to gnc-vcs-info.h.in) +# - DST (full path to destination for gnc-vcs-info.h) +# - VCS_INFO_FILE (full path to gnc-vcs-info.h - can be in source tree (release builds) or build tree (git builds)) +# - DATADIR_BUILD (path to applicication data directory, typically {CMAKE_BINARY_DIR}/share) + +include (${SRC_DIR}/cmake/version-info2env.cmake) +versioninfo2env (${VCS_INFO_FILE}) +configure_file(${SRC} ${DST} ) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 7e7f812944..79f3c98721 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -54,14 +54,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tip_of_the_day.list DESTINATION ${CMA file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tip_of_the_day.list DESTINATION ${DATADIR_BUILD}/gnucash) -# --- -if (BUILDING_FROM_VCS) - set(VCS_INFO_BASE_DIR ${CMAKE_BINARY_DIR}) -else() - set(VCS_INFO_BASE_DIR ${CMAKE_SOURCE_DIR}) -endif() -set(VCS_INFO_FILE ${VCS_INFO_BASE_DIR}/libgnucash/core-utils/gnc-vcs-info.h) - add_custom_command(OUTPUT gnucash.1 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.1.in gnc-vcs-info COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/gnucash.1.in diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt index 970606c8be..6291f27c57 100644 --- a/gnucash/gnome/CMakeLists.txt +++ b/gnucash/gnome/CMakeLists.txt @@ -153,23 +153,30 @@ install(TARGETS gnc-gnome # No headers to install -# FIXME: where does LC_ALL=C come from? +add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in +DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in ${VCS_INFO_FILE} + COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in + -D DST=${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in + -D VCS_INFO_FILE=${VCS_INFO_FILE} + -D SRC_DIR=${CMAKE_SOURCE_DIR} + -P ${CMAKE_SOURCE_DIR}/cmake/configure-appdata.cmake) if (${GETTEXT_VERSION_STRING} VERSION_LESS 0.19.6) # Gettext is too old to be able to merge an appdata file. # Fall back to providing an unmerged (and hence untranslated) appdata file. - configure_file (${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in + configure_file (${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml COPYONLY) else() + # FIXME: where does LC_ALL=C come from? add_custom_command ( OUTPUT gnucash.appdata.xml COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C ${GETTEXT_MSGFMT_EXECUTABLE} - --xml --template ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in + --xml --template ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in -d ${CMAKE_SOURCE_DIR}/po -o gnucash.appdata.xml - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in gnc-vcs-info ) endif() diff --git a/gnucash/gnome/gnucash.appdata.xml.in b/gnucash/gnome/gnucash.appdata.xml.in index 0f2dae42f5..11e77b592f 100644 --- a/gnucash/gnome/gnucash.appdata.xml.in +++ b/gnucash/gnome/gnucash.appdata.xml.in @@ -1,4 +1,5 @@ + org.gnucash.GnuCash GnuCash @@ -33,6 +34,10 @@ gnucash.desktop CC0-1.0 GPL-2.0+ + + + + https://www.gnucash.org/images/features/feature_accounts_lg.png diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt index 647b220413..3960cd7c46 100644 --- a/libgnucash/core-utils/CMakeLists.txt +++ b/libgnucash/core-utils/CMakeLists.txt @@ -41,6 +41,16 @@ set(sysconfdir ${CMAKE_INSTALL_FULL_SYSCONFDIR}) set(localedir "${CMAKE_INSTALL_FULL_DATAROOTDIR}/locale") configure_file(gncla-dir.h.in gncla-dir.h) + + +# --- +if (BUILDING_FROM_VCS) + set(VCS_INFO_BASE_DIR ${CMAKE_BINARY_DIR}) +else() + set(VCS_INFO_BASE_DIR ${CMAKE_SOURCE_DIR}) +endif() +set(VCS_INFO_FILE ${VCS_INFO_BASE_DIR}/libgnucash/core-utils/gnc-vcs-info.h CACHE STRING "path to gnc-vcs-dir") + ### Create gnc-vcs-info.h # This can only be done when building from a vcs (git/svn/bzr/svk) working directory. # This file is shipped in the distribution tarball, so no need to generate it in that case anyway. @@ -63,7 +73,7 @@ add_custom_target(gnc-vcs-info ALL -P ${CMAKE_SOURCE_DIR}/cmake/git2version-info.cmake ) else(BUILDING_FROM_VCS) - add_custom_target(gnc-vcs-info DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnc-vcs-info.h) + add_custom_target(gnc-vcs-info DEPENDS ${VCS_INFO_FILE}) endif(BUILDING_FROM_VCS) dist_add_generated (${BUILDING_FROM_VCS} gnc-vcs-info.h) ### Compile library