Fix make dist on a clean checkout

cmake with unix makefiles fails to resolve dist dependencies
added from COPY_FROM_BUILD if these dependencies aren't built yet.

This commit replaces the COPY_FROM_BUILD based logic with two new functions
'dist_add_configured' and 'dist_add_generated' to indicate which files should
be included in the dist tarball. The latter also adds a target level dependency
to the dist tarball custom command. Hence the former should
be used for files that get generated during a cmake run while the latter
should be used for files generated as the result of a 'make/ninja-build' run
(like files for which an add_custom_command rule exists).

Note: this commit also temporarily disables the dist target when building
from a tarball (and hence it won't be tested in distcheck either). This
will be handled in a future commit.
pull/271/head
Geert Janssens 8 years ago
parent 1258a2adfd
commit 3dff4e5211

@ -33,6 +33,10 @@ SET (GNUCASH_RESAVE_VERSION "19920")
SET(GETTEXT_PACKAGE "gnucash")
# Clear cache variables that will be filled later during the cmake run
unset(dist_generated CACHE)
unset(dist_generated_depends CACHE)
# Extra cmake macros
SET (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/common/cmake_modules;${CMAKE_MODULE_PATH}")
# CMake does a non-recursive build that puts the final build product directories in the build root. Some code needs to know this.
@ -763,9 +767,24 @@ ADD_SUBDIRECTORY (util)
# it contains post-install actions to execute.
ADD_SUBDIRECTORY(cmake)
############################ BEGIN MAKE DIST #################
# Generate the ChangeLog
if (BUILDING_FROM_VCS)
add_custom_target(ChangeLog ALL
COMMAND ${GIT_EXECUTABLE} log --format=\"%ad %aN %n%n%x09* %s%d%n\" --date=short --since=2018-01-01 > ${CMAKE_BINARY_DIR}/ChangeLog
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
dist_add_generated(ChangeLog ChangeLog)
install(FILES ${CMAKE_BINARY_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
else()
install(FILES ${CMAKE_SOURCE_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
endif()
############################ BEGIN MAKE DIST #################
# For now only enable the dist target when building from git
# the generation of dist_generated should be improved to work
# also when running from a tarball before that can be generalized.
IF (BUILDING_FROM_VCS)
SET(PACKAGE_PREFIX "${PACKAGE}-${PACKAGE_VERSION}")
SET(DIST_FILE "${PACKAGE_PREFIX}.tar")
@ -800,12 +819,6 @@ ENDIF()
STRING(REPLACE ";" "\n" ALL_DIST_LINES "${ALL_DIST}")
FILE(WRITE ${CMAKE_BINARY_DIR}/dist_manifest.txt ${ALL_DIST_LINES})
SET(DIST_GENERATED_FILES2 "")
FOREACH(file ${COPY_FROM_BUILD})
LIST(APPEND DIST_GENERATED_FILES2 ${BUILD_SOURCE_DIR}/${file})
ENDFOREACH()
ADD_CUSTOM_COMMAND(OUTPUT ${DIST_FILE}.gz ${DIST_FILE}.bz2
COMMAND ${CMAKE_COMMAND}
-D CMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/common/cmake_modules
@ -815,10 +828,11 @@ ADD_CUSTOM_COMMAND(OUTPUT ${DIST_FILE}.gz ${DIST_FILE}.bz2
-D BUILDING_FROM_VCS=${BUILDING_FROM_VCS}
-D SHELL=${SHELL}
-D WITH_GNUCASH=${WITH_GNUCASH}
"-Ddist_generated=\"${dist_generated}\""
-P ${CMAKE_SOURCE_DIR}/common/cmake_modules/MakeDist.cmake
DEPENDS
${ALL_DIST} ${DIST_GENERATED_FILES2} gnc-vcs-info iso-4217-c gnc-warnings-c gnucash-design-info ChangeLog gnucash-pot
${ALL_DIST} ${dist_generated_depends}
)
ADD_CUSTOM_TARGET(dist DEPENDS ${DIST_FILE}.gz ${DIST_FILE}.bz2)
@ -835,6 +849,7 @@ ADD_CUSTOM_TARGET(distcheck DEPENDS dist
ENDIF()
############################# END MAKE DIST #################
# uninstall target
@ -876,18 +891,6 @@ IF (WIN32)
)
ENDIF()
# Generate the ChangeLog
IF (BUILDING_FROM_VCS)
ADD_CUSTOM_TARGET(ChangeLog ALL
COMMAND ${GIT_EXECUTABLE} log --format=\"%ad %aN %n%n%x09* %s%d%n\" --date=short --since=2018-01-01 > ${CMAKE_BINARY_DIR}/ChangeLog
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
INSTALL(FILES ${CMAKE_BINARY_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
ELSE()
INSTALL(FILES ${CMAKE_SOURCE_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
ENDIF()
#Link LICENSE to COPYING so that people expecting to find it,
#will. COPYING is normally linked by autogen.sh to the latest
#automake-provided version.

@ -46,6 +46,8 @@ IF (BUILDING_FROM_VCS)
${CMAKE_SOURCE_DIR}/libgnucash/engine/engine-common.i
${GNUCASH_CORE_C_INCLUDES}
)
add_custom_target(swig-gnucash-core-c-py DEPENDS swig-gnucash-core)
dist_add_generated(swig-gnucash-core-c-py gnucash_core_c.py)
ELSE()
SET (SWIG_GNUCASH_CORE_C gnucash_core.c)
SET (SWIG_GNUCASH_CORE_C_PY ${CMAKE_CURRENT_SOURCE_DIR}/gnucash_core_c.py)

@ -17,7 +17,7 @@ IF (BUILDING_FROM_VCS)
ELSE()
SET (SWIG_RUNTIME_H ${CMAKE_CURRENT_SOURCE_DIR}/swig-runtime.h PARENT_SCOPE)
ENDIF()
dist_add_generated(swig-runtime-h swig-runtime.h)
SET_LOCAL_DIST(common_DIST_local CMakeLists.txt ${common_EXTRA_DIST})

@ -4,41 +4,59 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
MACRO (GNC_ADD_SWIG_COMMAND _target _output _input)
ADD_CUSTOM_COMMAND (
OUTPUT ${_output}
DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
COMMAND ${SWIG_EXECUTABLE} -guile ${SWIG_ARGS} -Linkage module -I${CMAKE_SOURCE_DIR}/libgnucash/engine -I${CMAKE_SOURCE_DIR}/common -o ${_output} ${_input}
)
ADD_CUSTOM_TARGET(${_target} DEPENDS ${_output})
ENDMACRO (GNC_ADD_SWIG_COMMAND)
MACRO (GNC_ADD_SWIG_PYTHON_COMMAND _target _output _input)
set (DEFAULT_SWIG_PYTHON_FLAGS
-python
-Wall -Werror
${SWIG_ARGS}
)
set (DEFAULT_SWIG_PYTHON_C_INCLUDES
${GLIB2_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/common
${CMAKE_SOURCE_DIR}/libgnucash/engine
${CMAKE_SOURCE_DIR}/libgnucash/app-utils
)
set (PYTHON_SWIG_FLAGS ${DEFAULT_SWIG_PYTHON_FLAGS})
foreach (dir ${DEFAULT_SWIG_PYTHON_C_INCLUDES})
list (APPEND PYTHON_SWIG_FLAGS "-I${dir}")
endforeach (dir)
ADD_CUSTOM_COMMAND(OUTPUT ${_output}
COMMAND ${SWIG_EXECUTABLE} ${PYTHON_SWIG_FLAGS} -o ${_output} ${_input}
DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
)
ADD_CUSTOM_TARGET(${_target} ALL DEPENDS ${_output} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${_input} ${ARGN})
ENDMACRO()
macro (GNC_ADD_SWIG_COMMAND _target _output _input)
add_custom_command (
OUTPUT ${_output}
DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
COMMAND ${SWIG_EXECUTABLE} -guile ${SWIG_ARGS} -Linkage module -I${CMAKE_SOURCE_DIR}/libgnucash/engine -I${CMAKE_SOURCE_DIR}/common -o ${_output} ${_input}
)
add_custom_target(${_target} DEPENDS ${_output})
if (BUILDING_FROM_VCS)
set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
else()
set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()
file(RELATIVE_PATH generated ${BUILD_SOURCE_DIR} ${_output})
dist_add_generated(${_target} ${generated})
endmacro (GNC_ADD_SWIG_COMMAND)
macro (GNC_ADD_SWIG_PYTHON_COMMAND _target _output _input)
set (DEFAULT_SWIG_PYTHON_FLAGS
-python
-Wall -Werror
${SWIG_ARGS}
)
set (DEFAULT_SWIG_PYTHON_C_INCLUDES
${GLIB2_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/common
${CMAKE_SOURCE_DIR}/libgnucash/engine
${CMAKE_SOURCE_DIR}/libgnucash/app-utils
)
set (PYTHON_SWIG_FLAGS ${DEFAULT_SWIG_PYTHON_FLAGS})
foreach (dir ${DEFAULT_SWIG_PYTHON_C_INCLUDES})
list (APPEND PYTHON_SWIG_FLAGS "-I${dir}")
endforeach (dir)
add_custom_command(OUTPUT ${_output}
COMMAND ${SWIG_EXECUTABLE} ${PYTHON_SWIG_FLAGS} -o ${_output} ${_input}
DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
)
add_custom_target(${_target} ALL DEPENDS ${_output} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${_input} ${ARGN})
if (BUILDING_FROM_VCS)
set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
else()
set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()
file(RELATIVE_PATH generated ${BUILD_SOURCE_DIR} ${_output})
dist_add_generated(${_target} ${generated})
endmacro()

@ -1,15 +1,13 @@
# This file implements the process of making source distribution tarballs. It expects to find list in
# 'dist_manifest.txt' of all of the files to be included in the distribution, EXCEPT those
# files that are generated. The list of generated files is specified in MakeDistFiles.cmake in the
# COPY_FROM_BUILD and COPY_FROM_BUILD_2 variables.
# files that are generated. The list of generated files handled via the 'dist_generated' cmake cache variable
#
# Given all of these files, the procedure is to:
# 1. Remove any existing dist directory and make a new one.
# 2. Copy of all the files in dist_manifest.text, COPY_FROM_BUILD and COPY_FROM_BUILD_2
# 2. Copy of all the files in dist_manifest.text and ${dist_generated}
# into the dist directory.
# 3. Run autogen.sh if build a dist from Git.
# 4. Create the tarball and compress it with gzip and bzip2.
# 5. Then remove the dist directory.
# 3. Create the tarball and compress it with gzip and bzip2.
# 4. Then remove the dist directory.
include(${CMAKE_MODULE_PATH}/MakeDistFiles.cmake)
@ -48,7 +46,7 @@ FUNCTION(MAKE_DIST PACKAGE_PREFIX GNUCASH_SOURCE_DIR BUILD_SOURCE_DIR BUILDING_F
# -- Copy in build products that are distributed.
FOREACH(file ${COPY_FROM_BUILD} ${COPY_FROM_BUILD_2})
FOREACH(file ${dist_generated})
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_SOURCE_DIR}/${file} ${PACKAGE_PREFIX}/${file})
IF (NOT EXISTS ${PACKAGE_PREFIX}/${file})
MESSAGE(FATAL_ERROR "Copy of ${BUILD_SOURCE_DIR}/${file} to dist dir '${PACKAGE_PREFIX}' failed.")

@ -63,7 +63,6 @@ FUNCTION(RUN_DIST_CHECK PACKAGE_PREFIX EXT)
)
# Run ninja install
EXECUTE_PROCESS_AND_CHECK_RESULT(
COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND} install
WORKING_DIRECTORY ${BUILD_DIR}
@ -77,12 +76,12 @@ FUNCTION(RUN_DIST_CHECK PACKAGE_PREFIX EXT)
ERROR_MSG "Ninja check failed."
)
# Run ninja dist
EXECUTE_PROCESS_AND_CHECK_RESULT(
COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND} dist
WORKING_DIRECTORY ${BUILD_DIR}
ERROR_MSG "Ninja dist failed."
)
# # Run ninja dist
# EXECUTE_PROCESS_AND_CHECK_RESULT(
# COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND} dist
# WORKING_DIRECTORY ${BUILD_DIR}
# ERROR_MSG "Ninja dist failed."
# )
MESSAGE("distcheck complete.")

@ -30,57 +30,32 @@ FUNCTION(EXECUTE_PROCESS_AND_CHECK_RESULT)
ENDIF()
ENDFUNCTION()
# This is a list of files generated at build time that
# should be copied into the dist tarball. An item in
# this list should be a file, not a directory or glob.
# File in this list become dependenices of the 'dist'
# target.
SET(COPY_FROM_BUILD
ChangeLog
doc/gnucash.1
libgnucash/app-utils/swig-app-utils-guile.c
libgnucash/app-utils/swig-app-utils-python.c
gnucash/gnucash.rc
libgnucash/core-utils/gnc-vcs-info.h
libgnucash/core-utils/swig-core-utils-guile.c
libgnucash/core-utils/swig-core-utils-python.c
libgnucash/doc/design/gnucash-design.info
libgnucash/engine/iso-4217-currencies.c
libgnucash/engine/swig-engine.c
libgnucash/gnc-module/swig-gnc-module.c
libgnucash/gnc-module/test/mod-bar/swig-bar.c
libgnucash/gnc-module/test/mod-baz/swig-baz.c
libgnucash/gnc-module/test/mod-foo/swig-foo.c
gnucash/gnome/gnucash.desktop.in
gnucash/gnome/swig-gnome.c
gnucash/gnome-utils/gnc-warnings.c
gnucash/gnome-utils/swig-gnome-utils.c
gnucash/html/swig-gnc-html.c
bindings/python/gnucash_core.c
gnucash/report/report-gnome/swig-report-gnome.c
gnucash/report/report-system/swig-report-system.c
libgnucash/scm/build-config.scm
common/swig-runtime.h
common/test-core/swig-unittest-support-guile.c
common/test-core/swig-unittest-support-python.c
)
# This list is similiar to the COPY_FROM_BUILD list
# above, except that we don't create an explicit
# dependency on this for the 'dist' target. I need
# to fix the creation of these files so that we
# can add them as dependencies for 'dist'. These
# file are not generated using CONFIGURE_FILE(),
# so CMake does not realize these are generated files.
SET(COPY_FROM_BUILD_2
po/gnucash.pot
libgnucash/doc/design/stamp-vti
libgnucash/doc/design/version.texi
bindings/python/gnucash_core_c.py
common/test-core/unittest_support.py
)
# These macros can be called to add a generated file (as opposed to a source file)
# to the distribution tarball
# - dist_add_configured will only add the file to the tarball. This macro
# should be used for files that are generated during a cmake run (for example with configure_file)
# - dist_add_generated will add the file to the tarball and generate a dependency
# for the file to the dist target. This macro should be used for all files that
# will be generated during a "make" or "ninja-build" run
macro(dist_add_configured _configured)
if (BUILDING_FROM_VCS)
set(BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
set(CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
else()
set(BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR})
set(CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()
file(RELATIVE_PATH rel_conf ${BUILD_SOURCE_DIR} ${CURRENT_BUILD_SOURCE_DIR}/${_configured})
set(local_generated ${dist_generated})
list(APPEND local_generated ${rel_conf})
set(dist_generated ${local_generated} CACHE INTERNAL "generated files that will be included in the distribution tarball")
endmacro()
macro(dist_add_generated _target _generated)
dist_add_configured(${_generated})
set(local_generated_depends ${dist_generated_depends})
list(APPEND local_generated_depends ${_target})
set(dist_generated_depends ${local_generated_depends} CACHE INTERNAL "global targets for generated files that will be included in the distribution tarball")
endmacro()

@ -33,6 +33,8 @@ IF (BUILDING_FROM_VCS)
${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i ${test_core_HEADERS})
SET (SWIG_UNITTEST_SUPPORT_PYTHON_C ${CMAKE_CURRENT_BINARY_DIR}/swig-unittest-support-python.c)
GNC_ADD_SWIG_PYTHON_COMMAND (swig-unittest-support-python ${SWIG_UNITTEST_SUPPORT_PYTHON_C} ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i)
add_custom_target(unittest-support-py DEPENDS swig-unittest-support-python)
dist_add_generated(unittest-support-py unittest_support.py)
ELSE()
SET (SWIG_UNITTEST_SUPPORT_GUILE_C swig-unittest-support-guile.c)
SET (SWIG_UNITTEST_SUPPORT_PYTHON_C swig-unittest-support-python.c)

@ -84,5 +84,6 @@ ADD_CUSTOM_COMMAND(OUTPUT gnucash.1
-P ${CMAKE_CURRENT_BINARY_DIR}/manpage.cmake
)
ADD_CUSTOM_TARGET(gnucash-manpage DEPENDS gnucash.1)
dist_add_generated(gnucash-manpage gnucash.1)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)

@ -110,7 +110,8 @@ SET(GNUCASH_BIN_INSTALL_NAME "gnucash")
SET(VALGRIND_OUTDIR ${BINDIR_BUILD})
CONFIGURE_FILE(gnucash.rc.in gnucash.rc @ONLY NEWLINE_STYLE WIN32)
configure_file(gnucash.rc.in gnucash.rc @ONLY NEWLINE_STYLE WIN32)
dist_add_configured(gnucash.rc)
configure_file(gnucash-valgrind.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/gnucash-valgrind @ONLY)
FILE(COPY ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/gnucash-valgrind

@ -33,6 +33,8 @@ ADD_CUSTOM_COMMAND(
)
ADD_CUSTOM_TARGET(gnc-warnings-c DEPENDS ${GNC_WARNINGS_C})
dist_add_generated(gnc-warnings-c gnc-warnings.c)
# FIXME why is gnc-warnings.c added to dist and gnc-warnings.h not ? I think neither is necessary...
#GTK before 3.14 didn't have GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK
if (NOT have_mod_mask)

@ -184,7 +184,8 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml DESTINATION ${CMA
#=======
CONFIGURE_FILE(gnucash.desktop.in.in gnucash.desktop.in)
configure_file(gnucash.desktop.in.in gnucash.desktop.in)
dist_add_configured(gnucash.desktop.in)
ADD_CUSTOM_COMMAND(

@ -122,6 +122,7 @@ ENDIF()
ELSE(BUILDING_FROM_VCS)
ADD_CUSTOM_TARGET(gnc-vcs-info DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnc-vcs-info.h)
ENDIF(BUILDING_FROM_VCS)
dist_add_generated(gnc-vcs-info gnc-vcs-info.h)
### Compile library
SET(core_utils_noinst_HEADERS

@ -28,6 +28,8 @@ SET(VERSION_TEXI_IN
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.texi ${VERSION_TEXI_IN})
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/stamp-vti ${VERSION_TEXI_IN})
dist_add_configured(version.texi)
dist_add_configured(stamp-vti)
FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" TEXI_BINARY_DIR)
FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/gnucash-design.texi" TEXI_SOURCE_FILE)
@ -47,5 +49,6 @@ if (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
)
ENDIF()
endif (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
dist_add_generated(gnucash-design-info gnucash-design.info)
SET_DIST_LIST(doc_design_DIST CMakeLists.txt gnucash-design.texi ${gnucash_design_TEXINFOS})

@ -134,6 +134,7 @@ ADD_CUSTOM_COMMAND (
${LIBXSLT_XSLTPROC_EXECUTABLE} -o ${ISO_4217_C} "${CMAKE_CURRENT_SOURCE_DIR}/iso-currencies-to-c.xsl" "${CMAKE_CURRENT_SOURCE_DIR}/iso-4217-currencies.xml"
)
ADD_CUSTOM_TARGET(iso-4217-c DEPENDS ${ISO_4217_C})
dist_add_generated(iso-4217-c iso-4217-currencies.c)
SET (engine_SOURCES
Account.cpp

@ -8,6 +8,7 @@ SET (scm_SCHEME_4
)
configure_file(build-config.scm.in ${BUILD_CONFIG_SCM})
dist_add_configured(build-config.scm)
SET(GUILE_DEPENDS scm-core-utils scm-gnc-module)

@ -176,6 +176,7 @@ ELSE()
add_custom_target(gnucash-pot
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.pot)
ENDIF()
dist_add_generated(gnucash-pot gnucash.pot)
ADD_CUSTOM_TARGET(check-po
COMMAND ${CMAKE_COMMAND}

Loading…
Cancel
Save