diff --git a/CMakeLists.txt b/CMakeLists.txt index e3221a11a2..1194024576 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,6 @@ option (DISABLE_DEPRECATED_GNOME "don't use deprecated gnome functions" OFF) set(COMPILE_GSCHEMAS ON CACHE BOOL "Compile the GSettings schema") 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 @@ -159,10 +158,6 @@ endif() # 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 -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 # GnuCash has been followed and that these dependencies live underneath something like C:/GCDEV, which @@ -265,11 +260,9 @@ endif (WIN32) # ############################################################ # SWIG -if(GENERATE_SWIG_WRAPPERS) - find_package (SWIG 2.0.10 REQUIRED) - include (${SWIG_USE_FILE}) - string(REGEX MATCH "^[0-9]+[.]" SWIG_MAJOR ${SWIG_VERSION}) -endif() +find_package (SWIG 2.0.10 REQUIRED) +include (${SWIG_USE_FILE}) +string(REGEX MATCH "^[0-9]+[.]" SWIG_MAJOR ${SWIG_VERSION}) # Find Guile and determine which version we are using. # Look for guile versions in this order: 2.2 > 2.0 diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 087ec67e9f..b06b7d8627 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -13,19 +13,13 @@ set(common_EXTRA_DIST platform.h) -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 ( - OUTPUT ${SWIG_RUNTIME_H} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - COMMAND ${SWIG_EXECUTABLE} -guile -external-runtime ${SWIG_RUNTIME_H} - ) -else() - set (SWIG_RUNTIME_H ${CMAKE_CURRENT_SOURCE_DIR}/swig-runtime.h) -endif() -dist_add_generated (${GENERATE_SWIG_WRAPPERS} swig-runtime.h) - +set (SWIG_RUNTIME_H ${CMAKE_CURRENT_BINARY_DIR}/swig-runtime.h) +# Command to generate the swig-runtime.h header +add_custom_command ( + OUTPUT ${SWIG_RUNTIME_H} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + COMMAND ${SWIG_EXECUTABLE} -guile -external-runtime ${SWIG_RUNTIME_H} +) add_custom_target (swig-runtime-h DEPENDS ${SWIG_RUNTIME_H}) set_local_dist(common_DIST_local CMakeLists.txt ${common_EXTRA_DIST}) diff --git a/common/cmake_modules/GncAddSwigCommand.cmake b/common/cmake_modules/GncAddSwigCommand.cmake index fa4f09d3c0..4b96b415b4 100644 --- a/common/cmake_modules/GncAddSwigCommand.cmake +++ b/common/cmake_modules/GncAddSwigCommand.cmake @@ -5,98 +5,67 @@ # For details see the accompanying COPYING-CMAKE-SCRIPTS file. # gnc_add_swig_guile_command is used to generate guile swig wrappers -# it will only really generate the wrappers when building from git -# when building from tarball it will set up everything so the version of the wrapper -# from the tarball will be used instead # - _target is the name of a global target that will be set for this wrapper file, # this can be used elsewhere to create a depencency on this wrapper # - _out_var will be set to the full path to the generated wrapper file -# when building from git, it points to the actually generated file -# however when building from a tarball, it will point to the version from the tarball instead -# - _output is the name of the wrapper file to generate (or to look up in the tarball) +# - _output is the name of the wrapper file to generate # - _input is the swig interface file (*.i) to generate this wrapper from # Any additional parameters will be used as dependencies for this wrapper target macro (gnc_add_swig_guile_command _target _out_var _output _input) - if (GENERATE_SWIG_WRAPPERS) - set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}) - set(SW_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR}) - else() - set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - set(SW_BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR}) - endif() - + set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}) + set(SW_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR}) 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 (GENERATE_SWIG_WRAPPERS) - add_custom_command ( - OUTPUT ${outfile} - 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 ${outfile} ${_input} - ) - add_custom_target(${_target} DEPENDS ${outfile}) - endif() - - # Add the output file outfile to the dist tarball - dist_add_generated (${GENERATE_SWIG_WRAPPERS} ${_output}) + add_custom_command ( + OUTPUT ${outfile} + 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 ${outfile} ${_input} + ) + add_custom_target(${_target} DEPENDS ${outfile}) endmacro (gnc_add_swig_guile_command) # gnc_add_swig_python_command is used to generate python swig wrappers -# it will only really generate the wrappers when building from git -# when building from tarball it will set up everything so the version of the wrapper # from the tarball will be used instead # - _target is the name of a global target that will be set for this wrapper file, # this can be used elsewhere to create a depencency on this wrapper # - _out_var will be set to the full path to the generated wrapper file -# when building from git, it points to the actually generated file -# however when building from a tarball, it will point to the version from the tarball instead # - _py_out_var is the same but for the python module that's generated together with the wrapper -# - _output is the name of the wrapper file to generate (or to look up in the tarball) +# - _output is the name of the wrapper file to generate # - _py_output is the name of the python module associated with this wrapper # - _input is the swig interface file (*.i) to generate this wrapper from # 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 (GENERATE_SWIG_WRAPPERS) - set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}) - set(SW_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR}) - else() - set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - set(SW_BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR}) - endif() - + set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}) + set(SW_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR}) 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 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 (GENERATE_SWIG_WRAPPERS) - set (DEFAULT_SWIG_PYTHON_FLAGS - -python -py3 - -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 ${outfile} ${py_outfile} - COMMAND ${SWIG_EXECUTABLE} ${PYTHON_SWIG_FLAGS} -o ${outfile} ${_input} - DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN} - ) - add_custom_target(${_target} ALL DEPENDS ${outfile} ${py_outfile} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${_input} ${ARGN}) - endif() + set (DEFAULT_SWIG_PYTHON_FLAGS + -python -py3 + -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 + ) - # Add the output files _output and _py_output to the dist tarball - dist_add_generated (${GENERATE_SWIG_WRAPPERS} ${_output} ${_py_output}) + 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 ${outfile} ${py_outfile} + COMMAND ${SWIG_EXECUTABLE} ${PYTHON_SWIG_FLAGS} -o ${outfile} ${_input} + DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN} + ) + add_custom_target(${_target} ALL DEPENDS ${outfile} ${py_outfile} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${_input} ${ARGN}) endmacro() diff --git a/common/cmake_modules/MakeDistFiles.cmake b/common/cmake_modules/MakeDistFiles.cmake index 277374dc12..a32a11908a 100644 --- a/common/cmake_modules/MakeDistFiles.cmake +++ b/common/cmake_modules/MakeDistFiles.cmake @@ -39,10 +39,9 @@ endfunction() # 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: +# in this configuration. At the time of this writing there is one +# cmake variable that controls 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})