mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-21 08:34:15 -06:00
Rework version-info rules to allow building from github downloaded zip archives
This commit is contained in:
parent
3f8b97bb2e
commit
bd6e79b4d6
@ -154,14 +154,23 @@ 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 install git or set GIT_EXECUTABLE.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Determine whether or not we have to generate a gnc-vcs-info.h file
|
||||
# Distribution tarballs have this file in the source tree
|
||||
# Git checkouts or zipfiles downloaded straight from github won't have it
|
||||
# and require us to build it.
|
||||
if (BUILDING_FROM_VCS OR NOT EXISTS "${CMAKE_SOURCE_DIR}/libgnucash/core-utilsgnc-vcs-info.h")
|
||||
set(VCS_INFO_BASE_DIR ${CMAKE_BINARY_DIR})
|
||||
set(GENERATE_VCS_INFO "Yes")
|
||||
else()
|
||||
set(VCS_INFO_BASE_DIR ${CMAKE_SOURCE_DIR})
|
||||
set(GENERATE_VCS_INFO "No")
|
||||
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)
|
||||
# As the file's path is needed by several other build rules, we already define
|
||||
# that here. The actual build rules (if needed) are in libgnucash/core-utils.
|
||||
set(VCS_INFO_FILE ${VCS_INFO_BASE_DIR}/libgnucash/core-utils/gnc-vcs-info.h CACHE STRING "path to gnc-vcs-info.h file")
|
||||
|
||||
|
||||
if (WIN32)
|
||||
# Help Windows find the various dependencies. We assume here that the standard advice for building
|
||||
|
@ -8,7 +8,15 @@ if (APPLE)
|
||||
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
|
||||
configure-totd.cmake git2version-info.cmake version-info2env.cmake
|
||||
set_dist_list(cmake_DIST
|
||||
CMakeLists.txt
|
||||
README_CMAKE.txt
|
||||
cmake_uninstall.cmake.in
|
||||
configure-appdata.cmake
|
||||
configure-gnucash-desktop.cmake
|
||||
configure-manpage.cmake
|
||||
configure-totd.cmake
|
||||
git2version-info.cmake
|
||||
no-vcs2version-info.cmake
|
||||
version-info2env.cmake
|
||||
)
|
||||
|
19
cmake/no-vcs2version-info.cmake
Normal file
19
cmake/no-vcs2version-info.cmake
Normal file
@ -0,0 +1,19 @@
|
||||
# Create the gnc-vcs-info.h file starting from a source directory that's
|
||||
# - not a git working directory
|
||||
# - not extracted from a distribution tarball
|
||||
# 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:
|
||||
# - PROJECT_VERSION
|
||||
# - SRC (full path to gnc-vcs-info.h.in)
|
||||
# - DST (full path to destination for gnc-vcs-info.h)
|
||||
|
||||
set (GNC_VCS_REV "${PROJECT_VERSION}-unknown-commit")
|
||||
string (TIMESTAMP GNC_VCS_REV_DATE "%Y-%m-%d")
|
||||
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)
|
@ -175,7 +175,7 @@ install(TARGETS gnc-gnome
|
||||
# No headers to install
|
||||
|
||||
set (GNC_APPDATA_IN ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml.in)
|
||||
if (NOT BUILDING_FROM_VCS)
|
||||
if (NOT GENERATE_VCS_INFO)
|
||||
# We're building from a dist tarball.
|
||||
# As a convenience to packagers we have included a pretranslated
|
||||
# intermediate appdata file in the dist tarball.
|
||||
@ -255,7 +255,7 @@ set_local_dist(gnome_DIST_local
|
||||
CMakeLists.txt gnome.i gnucash.appdata.xml.in.in gnucash.desktop.in.in
|
||||
gnucash.releases.xml ${gnc_gnome_noinst_HEADERS} ${gnc_gnome_SOURCES} ${gnome_SCHEME})
|
||||
|
||||
dist_add_generated(${BUILDING_FROM_VCS} gnucash.appdata.xml.in)
|
||||
dist_add_generated(${GENERATE_VCS_INFO} gnucash.appdata.xml.in)
|
||||
add_dependencies(gnucash-appdata dist-gnucash-gnome-gnucash-appdata-xml-in)
|
||||
|
||||
set(gnome_DIST ${gnome_DIST_local} ${test_gnome_DIST} PARENT_SCOPE)
|
||||
|
@ -87,38 +87,41 @@ set(localedir "${CMAKE_INSTALL_FULL_DATAROOTDIR}/locale")
|
||||
configure_file(gncla-dir.h.in gncla-dir.h)
|
||||
|
||||
|
||||
### 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.
|
||||
# The meta-cmake gymnastics here come from https://cmake.org/pipermail/cmake/2010-July/038015.html
|
||||
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-info.h file")
|
||||
### Build rules for gnc-vcs-info.h
|
||||
# When building from a distribution tarball simply use the one
|
||||
# found in the source tree.
|
||||
# When building from a git working directory extract the neede information from git.
|
||||
# Otherwise work from the PROJECT_VERSION variable and today's date, but annotate
|
||||
# the version info to indicate it's inaccurate.
|
||||
|
||||
if (BUILDING_FROM_VCS)
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h.in
|
||||
if (GENERATE_VCS_INFO)
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h.in
|
||||
"/* Autogenerated. Do not change. */
|
||||
#define GNC_VCS_REV \"@GNC_VCS_REV@\"
|
||||
#define GNC_VCS_REV_DATE \"@GNC_VCS_REV_DATE@\"
|
||||
#define GNC_VCS_REV_YEAR \"@GNC_VCS_REV_YEAR@\"
|
||||
#define GNC_VCS_REV_Y_M \"@GNC_VCS_REV_Y_M@\"
|
||||
")
|
||||
#define GNC_VCS_REV_Y_M \"@GNC_VCS_REV_Y_M@\"")
|
||||
|
||||
add_custom_target(gnc-vcs-info ALL
|
||||
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h
|
||||
COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h.in
|
||||
-D DST=${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h
|
||||
-D SRC_DIR=${CMAKE_SOURCE_DIR}
|
||||
-D SHELL="${SHELL}"
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/git2version-info.cmake
|
||||
)
|
||||
if (BUILDING_FROM_VCS)
|
||||
add_custom_target(gnc-vcs-info ALL
|
||||
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h
|
||||
COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h.in
|
||||
-D DST=${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h
|
||||
-D SRC_DIR=${CMAKE_SOURCE_DIR}
|
||||
-D SHELL="${SHELL}"
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/git2version-info.cmake)
|
||||
else()
|
||||
add_custom_target(gnc-vcs-info ALL
|
||||
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h
|
||||
COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h.in
|
||||
-D DST=${CMAKE_CURRENT_BINARY_DIR}/gnc-vcs-info.h
|
||||
-D PROJECT_VERSION=${PROJECT_VERSION}
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/no-vcs2version-info.cmake)
|
||||
endif()
|
||||
else()
|
||||
add_custom_target(gnc-vcs-info DEPENDS ${VCS_INFO_FILE})
|
||||
endif()
|
||||
dist_add_generated (${BUILDING_FROM_VCS} gnc-vcs-info.h)
|
||||
dist_add_generated (${GENERATE_VCS_INFO} gnc-vcs-info.h)
|
||||
|
||||
# Dist files
|
||||
set_local_dist(core_utils_DIST_local
|
||||
|
Loading…
Reference in New Issue
Block a user