mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add GENERATE_SWIG_WRAPPERS option to control the generation of swig wrappers independently of whether we're building from git
The swig wrappers don't really depend on git (but rather on swig) and there can be situations the builder wants to generate the wrappers also from a tar ball.
This commit is contained in:
parent
1805972646
commit
ff24970f5f
@ -71,6 +71,7 @@ OPTION (DISABLE_DEPRECATED_GNOME "don't use deprecated gnome functions" OFF)
|
||||
# These are also settable from the command line in a similar way.
|
||||
|
||||
SET(GNUCASH_BUILD_ID "" CACHE STRING "Overrides the GnuCash build identification (Build ID) which defaults to a description of the vcs commit from which gnucash is built. Distributions may want to insert a package management based version number instead")
|
||||
# GENERATE_SWIG_WRAPPERS - Controls whether to generate the swig wrappers for guile and python. If not set the wrappers will only be generated when building from a git worktree, commented out here, but will be evaluated later on in this file
|
||||
|
||||
# Check that all of the absolute install paths are inside
|
||||
# ${CMAKE_INSTALL_PREFIX}. If they're not, disable binreloc as it
|
||||
@ -144,7 +145,9 @@ IF (GNC_VCS_INFO_RESULT EQUAL 0)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
|
||||
# Determine whether to generate the swig wrappers.
|
||||
# By default they will only be generated when building from a git worktree
|
||||
set(GENERATE_SWIG_WRAPPERS ${BUILDING_FROM_VCS} CACHE BOOL "Controls whether to generate the swig wrappers for guile and python. If not set the wrappers will only be generated when building from a git worktree")
|
||||
|
||||
IF (WIN32)
|
||||
# Help Windows find the various dependencies. We assume here that the standard advice for building
|
||||
@ -273,7 +276,7 @@ ENDIF (WIN32)
|
||||
# ############################################################
|
||||
|
||||
# SWIG
|
||||
IF(BUILDING_FROM_VCS)
|
||||
IF(GENERATE_SWIG_WRAPPERS)
|
||||
FIND_PACKAGE (SWIG REQUIRED)
|
||||
INCLUDE (${SWIG_USE_FILE})
|
||||
ENDIF()
|
||||
@ -778,7 +781,7 @@ if (BUILDING_FROM_VCS)
|
||||
else()
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
endif()
|
||||
dist_add_generated(ChangeLog)
|
||||
dist_add_generated (${BUILDING_FROM_VCS} ChangeLog)
|
||||
|
||||
############################ BEGIN MAKE DIST #################
|
||||
|
||||
|
@ -13,7 +13,7 @@ SET(common_EXTRA_DIST
|
||||
platform.h)
|
||||
|
||||
|
||||
if (BUILDING_FROM_VCS)
|
||||
if (GENERATE_SWIG_WRAPPERS)
|
||||
set (SWIG_RUNTIME_H ${CMAKE_CURRENT_BINARY_DIR}/swig-runtime.h)
|
||||
# Command to generate the swig-runtime.h header
|
||||
add_custom_command (
|
||||
@ -24,7 +24,7 @@ if (BUILDING_FROM_VCS)
|
||||
else()
|
||||
set (SWIG_RUNTIME_H ${CMAKE_CURRENT_SOURCE_DIR}/swig-runtime.h)
|
||||
endif()
|
||||
dist_add_generated(swig-runtime.h)
|
||||
dist_add_generated (${GENERATE_SWIG_WRAPPERS} swig-runtime.h)
|
||||
|
||||
add_custom_target (swig-runtime-h DEPENDS ${SWIG_RUNTIME_H})
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
# Any additional parameters will be used as dependencies for this wrapper target
|
||||
macro (gnc_add_swig_guile_command _target _out_var _output _input)
|
||||
|
||||
if (BUILDING_FROM_VCS)
|
||||
if (GENERATE_SWIG_WRAPPERS)
|
||||
set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(SW_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
|
||||
else()
|
||||
@ -29,7 +29,7 @@ macro (gnc_add_swig_guile_command _target _out_var _output _input)
|
||||
set(outfile ${SW_CURR_BUILD_SOURCE_DIR}/${_output})
|
||||
set(${_out_var} ${outfile}) # This variable is set for convenience to use in the calling CMakeLists.txt
|
||||
|
||||
if (BUILDING_FROM_VCS)
|
||||
if (GENERATE_SWIG_WRAPPERS)
|
||||
add_custom_command (
|
||||
OUTPUT ${outfile}
|
||||
DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
|
||||
@ -39,7 +39,7 @@ macro (gnc_add_swig_guile_command _target _out_var _output _input)
|
||||
endif()
|
||||
|
||||
# Add the output file outfile to the dist tarball
|
||||
dist_add_generated(${_output})
|
||||
dist_add_generated (${GENERATE_SWIG_WRAPPERS} ${_output})
|
||||
endmacro (gnc_add_swig_guile_command)
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ endmacro (gnc_add_swig_guile_command)
|
||||
# Any additional parameters will be used as dependencies for this wrapper target
|
||||
macro (gnc_add_swig_python_command _target _out_var _py_out_var _output _py_output _input)
|
||||
|
||||
if (BUILDING_FROM_VCS)
|
||||
if (GENERATE_SWIG_WRAPPERS)
|
||||
set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(SW_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
|
||||
else()
|
||||
@ -73,7 +73,7 @@ macro (gnc_add_swig_python_command _target _out_var _py_out_var _output _py_outp
|
||||
set(py_outfile ${SW_CURR_BUILD_SOURCE_DIR}/${_py_output})
|
||||
set(${_py_out_var} ${py_outfile}) # This variable is set for convenience to use in the calling CMakeLists.txt
|
||||
|
||||
if (BUILDING_FROM_VCS)
|
||||
if (GENERATE_SWIG_WRAPPERS)
|
||||
set (DEFAULT_SWIG_PYTHON_FLAGS
|
||||
-python
|
||||
-Wall -Werror
|
||||
@ -98,5 +98,5 @@ macro (gnc_add_swig_python_command _target _out_var _py_out_var _output _py_outp
|
||||
endif()
|
||||
|
||||
# Add the output files _output and _py_output to the dist tarball
|
||||
dist_add_generated(${_output} ${_py_output})
|
||||
dist_add_generated (${GENERATE_SWIG_WRAPPERS} ${_output} ${_py_output})
|
||||
endmacro()
|
||||
|
@ -30,54 +30,62 @@ FUNCTION(EXECUTE_PROCESS_AND_CHECK_RESULT)
|
||||
ENDIF()
|
||||
ENDFUNCTION()
|
||||
|
||||
macro(make_target_name target source)
|
||||
if(BUILDING_FROM_VCS)
|
||||
set(TGT_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
|
||||
set(TGT_CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
else()
|
||||
set(TGT_BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
||||
set(TGT_CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
file(RELATIVE_PATH rel_file ${TGT_BUILD_SOURCE_DIR} ${TGT_CURRENT_BUILD_SOURCE_DIR}/${source})
|
||||
string(REPLACE "/" "-" target_tmp ${rel_file})
|
||||
string(REPLACE "_" "-" target_tmp2 ${target_tmp})
|
||||
string(REPLACE "." "-" ${target} dist-${target_tmp2})
|
||||
endmacro()
|
||||
|
||||
# These macros can be called to add generated files (as opposed to source files)
|
||||
# These functions can be called to add generated files (as opposed to source files)
|
||||
# to the distribution tarball
|
||||
# - dist_add_configured will only add the files to the tarball. This macro
|
||||
# - dist_add_configured will only add the files to the tarball. This function
|
||||
# should be used for files that are generated during a cmake run (for example with configure_file)
|
||||
# - dist_add_generated will add the files to the tarball and generate a dependency
|
||||
# for each file to the dist target. This macro should be used for all files that
|
||||
# for each file to the dist target. This function should be used for all files that
|
||||
# will be generated during a "make" or "ninja-build" run (for example those that are
|
||||
# the result of an add_custom_command)
|
||||
macro(dist_add_configured)
|
||||
if(BUILDING_FROM_VCS)
|
||||
set(CONF_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
|
||||
set(CONF_CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
#
|
||||
# Note that the files passed in these functions can still be in the source directory
|
||||
# This depends on whether or not the source is a git worktree or not and which
|
||||
# options were passed to cmake.
|
||||
# To determine this, the first parameter passed to this function should
|
||||
# be an indicator whether or not the files in the list are actually built
|
||||
# in this configuration. At the time of this writing there are two
|
||||
# cmake variables that control this, and hence can be used here:
|
||||
# BUILDING_FROM_VCS: is YES when building from a git source tree
|
||||
# GENERATE_SWIG_WRAPPERS: is YES when the swig wrappers should be built
|
||||
function (dist_add_generated_internal _needs_target _is_built)
|
||||
if (_is_built)
|
||||
set (DIST_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
|
||||
set (DIST_CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
else()
|
||||
set(CONF_BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
||||
set(CONF_CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set (DIST_BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
||||
set (DIST_CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
set(local_generated ${dist_generated})
|
||||
foreach(conf_file ${ARGN})
|
||||
file(RELATIVE_PATH rel_conf ${CONF_BUILD_SOURCE_DIR} ${CONF_CURRENT_BUILD_SOURCE_DIR}/${conf_file})
|
||||
list(APPEND local_generated ${rel_conf})
|
||||
set (local_generated ${dist_generated})
|
||||
foreach (conf_file ${ARGN})
|
||||
file (RELATIVE_PATH rel_conf ${DIST_BUILD_SOURCE_DIR} ${DIST_CURRENT_BUILD_SOURCE_DIR}/${conf_file})
|
||||
list (APPEND local_generated ${rel_conf})
|
||||
endforeach()
|
||||
set(dist_generated ${local_generated} CACHE INTERNAL "generated files that will be included in the distribution tarball")
|
||||
endmacro()
|
||||
set (dist_generated ${local_generated}
|
||||
CACHE INTERNAL "generated files that will be included in the distribution tarball")
|
||||
|
||||
macro(dist_add_generated)
|
||||
dist_add_configured(${ARGN})
|
||||
if (_needs_target)
|
||||
set (local_generated_depends ${dist_generated_depends})
|
||||
foreach (gen_file ${ARGN})
|
||||
file (RELATIVE_PATH rel_file ${DIST_BUILD_SOURCE_DIR} ${DIST_CURRENT_BUILD_SOURCE_DIR}/${gen_file})
|
||||
string (REPLACE "/" "-" target_tmp ${rel_file})
|
||||
string (REPLACE "_" "-" target_tmp2 ${target_tmp})
|
||||
string (REPLACE "." "-" dist_target dist-${target_tmp2})
|
||||
|
||||
set(local_generated_depends ${dist_generated_depends})
|
||||
foreach(gen_file ${ARGN})
|
||||
make_target_name(dist_target ${gen_file})
|
||||
add_custom_target(${dist_target} DEPENDS ${TGT_CURRENT_BUILD_SOURCE_DIR}/${gen_file}) # Note TGT_CURRENT_BUILD_SOURCE_DIR trickles down from the make_target macro
|
||||
list(APPEND local_generated_depends ${dist_target})
|
||||
endforeach()
|
||||
set(dist_generated_depends ${local_generated_depends} CACHE INTERNAL "global targets for generated files that will be included in the distribution tarball")
|
||||
endmacro()
|
||||
add_custom_target (${dist_target}
|
||||
DEPENDS ${DIST_CURRENT_BUILD_SOURCE_DIR}/${gen_file})
|
||||
list (APPEND local_generated_depends ${dist_target})
|
||||
endforeach()
|
||||
set (dist_generated_depends ${local_generated_depends}
|
||||
CACHE INTERNAL "global targets for generated files that will be included in the distribution tarball")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function (dist_add_configured _is_built)
|
||||
dist_add_generated_internal (NO ${_is_built} ${ARGN})
|
||||
endfunction()
|
||||
|
||||
function (dist_add_generated _is_built)
|
||||
dist_add_generated_internal (YES ${_is_built} ${ARGN})
|
||||
endfunction()
|
||||
|
@ -84,6 +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.1)
|
||||
dist_add_generated (${BUILDING_FROM_VCS} gnucash.1)
|
||||
|
||||
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
||||
|
@ -111,7 +111,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.h)
|
||||
dist_add_generated (${BUILDING_FROM_VCS} gnc-vcs-info.h)
|
||||
### Compile library
|
||||
|
||||
SET(core_utils_noinst_HEADERS
|
||||
|
@ -48,6 +48,6 @@ if (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
|
||||
)
|
||||
ENDIF()
|
||||
endif (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
|
||||
dist_add_generated(gnucash-design.info)
|
||||
dist_add_generated (${BUILDING_FROM_VCS} gnucash-design.info)
|
||||
|
||||
SET_DIST_LIST(doc_design_DIST CMakeLists.txt gnucash-design.texi ${gnucash_design_TEXINFOS})
|
||||
|
@ -179,7 +179,7 @@ IF(BUILDING_FROM_VCS)
|
||||
)
|
||||
add_custom_target (pot DEPENDS gnucash.pot)
|
||||
ENDIF()
|
||||
dist_add_generated(gnucash.pot)
|
||||
dist_add_generated (${BUILDING_FROM_VCS} gnucash.pot)
|
||||
|
||||
ADD_CUSTOM_TARGET(check-po
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
|
@ -690,7 +690,6 @@ libgnucash/engine/SX-ttinfo.c
|
||||
libgnucash/engine/Transaction.c
|
||||
libgnucash/engine/TransLog.c
|
||||
libgnucash/gnc-module/example/gncmod-example.c
|
||||
libgnucash/gnc-module/example/gnc-plugin.example.c
|
||||
libgnucash/gnc-module/gnc-module.c
|
||||
libgnucash/gnc-module/gnc-module.scm
|
||||
libgnucash/scm/fin.scm
|
||||
|
Loading…
Reference in New Issue
Block a user