From 49a936c1fd11bc06aa0ec78e5627d800c1fa7116 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 29 Jan 2018 18:54:13 +0100 Subject: [PATCH] Rewrite gnc_add_swig_guile_command to work in dist tarball as well When building from git it will add targets to generate the swig files. When building from tarball it will just point at the generated source files from the tarball. --- common/cmake_modules/GncAddSwigCommand.cmake | 47 +++++++++++++------ common/test-core/CMakeLists.txt | 13 +++-- gnucash/gnome-utils/CMakeLists.txt | 11 ++--- gnucash/gnome/CMakeLists.txt | 11 ++--- gnucash/html/CMakeLists.txt | 11 ++--- gnucash/report/report-gnome/CMakeLists.txt | 11 ++--- gnucash/report/report-system/CMakeLists.txt | 14 +++--- libgnucash/app-utils/CMakeLists.txt | 15 +++--- libgnucash/core-utils/CMakeLists.txt | 12 ++--- libgnucash/engine/CMakeLists.txt | 12 ++--- libgnucash/gnc-module/CMakeLists.txt | 12 ++--- .../gnc-module/test/mod-bar/CMakeLists.txt | 10 ++-- .../gnc-module/test/mod-baz/CMakeLists.txt | 10 ++-- .../gnc-module/test/mod-foo/CMakeLists.txt | 10 ++-- 14 files changed, 98 insertions(+), 101 deletions(-) diff --git a/common/cmake_modules/GncAddSwigCommand.cmake b/common/cmake_modules/GncAddSwigCommand.cmake index 44ba69b1f9..31e1e8661a 100644 --- a/common/cmake_modules/GncAddSwigCommand.cmake +++ b/common/cmake_modules/GncAddSwigCommand.cmake @@ -4,26 +4,43 @@ # 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}) +# 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) +# - input it 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 (BUILDING_FROM_VCS) - set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}) + set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}) + set(SW_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR}) else() - set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + set(SW_BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR}) endif() - # Add the output file _output to the dist tarball - file(RELATIVE_PATH generated ${BUILD_SOURCE_DIR} ${_output}) - dist_add_generated(${generated}) -endmacro (GNC_ADD_SWIG_COMMAND) + 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) + 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(${_output}) +endmacro (gnc_add_swig_guile_command) # gnc_add_swig_python_command is used to generate python swig wrappers diff --git a/common/test-core/CMakeLists.txt b/common/test-core/CMakeLists.txt index 095e152a18..7ebf5146dd 100644 --- a/common/test-core/CMakeLists.txt +++ b/common/test-core/CMakeLists.txt @@ -27,14 +27,13 @@ IF (UNIX) TARGET_COMPILE_OPTIONS(test-core PRIVATE -fPIC) ENDIF() -IF (BUILDING_FROM_VCS) - SET (SWIG_UNITTEST_SUPPORT_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-unittest-support-guile.c) - GNC_ADD_SWIG_COMMAND (swig-unittest-support-guile-c ${SWIG_UNITTEST_SUPPORT_GUILE_C} - ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i ${test_core_HEADERS}) -ELSE() - SET (SWIG_UNITTEST_SUPPORT_GUILE_C swig-unittest-support-guile.c) -ENDIF() +# Command to generate the swig-unittest-support-guile.c wrapper file +gnc_add_swig_guile_command (swig-unittest-support-guile-c + SWIG_UNITTEST_SUPPORT_GUILE_C swig-unittest-support-guile.c + ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i ${test_core_HEADERS} +) +# Command to generate the swig-unittest-support-python.c wrapper file gnc_add_swig_python_command (swig-unittest-support-python SWIG_UNITTEST_SUPPORT_PYTHON_C SWIG_UNITTEST_SUPPORT_PYTHON_PY swig-unittest-support-python.c unittest_support.py diff --git a/gnucash/gnome-utils/CMakeLists.txt b/gnucash/gnome-utils/CMakeLists.txt index 05aa9832a9..2ee23803e5 100644 --- a/gnucash/gnome-utils/CMakeLists.txt +++ b/gnucash/gnome-utils/CMakeLists.txt @@ -5,12 +5,11 @@ ADD_SUBDIRECTORY(gtkbuilder) ADD_SUBDIRECTORY(ui) ADD_SUBDIRECTORY(test) -IF (BUILDING_FROM_VCS) - SET (SWIG_GNOME_UTILS_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnome-utils.c) - GNC_ADD_SWIG_COMMAND (swig-gnome-utils-c ${SWIG_GNOME_UTILS_C} ${CMAKE_CURRENT_SOURCE_DIR}/gnome-utils.i) -ELSE() - SET (SWIG_GNOME_UTILS_C swig-gnome-utils.c) -ENDIF() +# Command to generate the swig-gnome-utils.c wrapper file +gnc_add_swig_guile_command (swig-gnome-utils-c + SWIG_GNOME_UTILS_C swig-gnome-utils.c + ${CMAKE_CURRENT_SOURCE_DIR}/gnome-utils.i +) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/gschemas/org.gnucash.warnings.gschema.xml.in.in ${CMAKE_CURRENT_BINARY_DIR}/gschemas/org.gnucash.warnings.gschema.xml.in) diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt index 70305b8155..5b54a951a7 100644 --- a/gnucash/gnome/CMakeLists.txt +++ b/gnucash/gnome/CMakeLists.txt @@ -59,12 +59,11 @@ SET (gnc_gnome_noinst_HEADERS window-autoclear.h ) -IF (BUILDING_FROM_VCS) - SET (SWIG_GNOME_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnome.c) - GNC_ADD_SWIG_COMMAND (swig-gnome-c ${SWIG_GNOME_C} ${CMAKE_CURRENT_SOURCE_DIR}/gnome.i ${gnc_gnome_HEADERS}) -ELSE() - SET (SWIG_GNOME_C swig-gnome.c) -ENDIF() +# Command to generate the swig-gnome.c wrapper file +gnc_add_swig_guile_command (swig-gnome-c + SWIG_GNOME_C swig-gnome.c + ${CMAKE_CURRENT_SOURCE_DIR}/gnome.i ${gnc_gnome_HEADERS} +) SET (gnc_gnome_SOURCES diff --git a/gnucash/html/CMakeLists.txt b/gnucash/html/CMakeLists.txt index eeb349139e..768a9c2fe5 100644 --- a/gnucash/html/CMakeLists.txt +++ b/gnucash/html/CMakeLists.txt @@ -9,12 +9,11 @@ SET (html_HEADERS gnc-html-webkit.h ) -IF (BUILDING_FROM_VCS) - SET (SWIG_GNC_HTML_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnc-html.c) - GNC_ADD_SWIG_COMMAND (swig-gnc-html-c ${SWIG_GNC_HTML_C} ${CMAKE_CURRENT_SOURCE_DIR}/gnc-html.i "${gncmod_html_HEADERS}") -ELSE() - SET (SWIG_GNC_HTML_C swig-gnc-html.c) -ENDIF() +# Command to generate the swig-gnc-html.c wrapper file +gnc_add_swig_guile_command (swig-gnc-html-c + SWIG_GNC_HTML_C swig-gnc-html.c + ${CMAKE_CURRENT_SOURCE_DIR}/gnc-html.i "${gncmod_html_HEADERS}" +) SET (html_SOURCES gncmod-html.c diff --git a/gnucash/report/report-gnome/CMakeLists.txt b/gnucash/report/report-gnome/CMakeLists.txt index ee2996a9f4..291e3866ae 100644 --- a/gnucash/report/report-gnome/CMakeLists.txt +++ b/gnucash/report/report-gnome/CMakeLists.txt @@ -8,12 +8,11 @@ SET (report_gnome_HEADERS window-report.h ) -IF (BUILDING_FROM_VCS) - SET (SWIG_REPORT_GNOME_C ${CMAKE_CURRENT_BINARY_DIR}/swig-report-gnome.c) - GNC_ADD_SWIG_COMMAND (swig-report-gnome-c ${SWIG_REPORT_GNOME_C} ${CMAKE_CURRENT_SOURCE_DIR}/report-gnome.i ${report_gnome_HEADERS}) -ELSE() - SET (SWIG_REPORT_GNOME_C swig-report-gnome.c) -ENDIF() +# Command to generate the swig-report-gnome.c wrapper file +gnc_add_swig_guile_command (swig-report-gnome-c + SWIG_REPORT_GNOME_C swig-report-gnome.c + ${CMAKE_CURRENT_SOURCE_DIR}/report-gnome.i ${report_gnome_HEADERS} +) SET (report_gnome_SOURCES dialog-report-column-view.c diff --git a/gnucash/report/report-system/CMakeLists.txt b/gnucash/report/report-system/CMakeLists.txt index 0ed1d8e0ea..01940baf0e 100644 --- a/gnucash/report/report-system/CMakeLists.txt +++ b/gnucash/report/report-system/CMakeLists.txt @@ -2,15 +2,13 @@ ADD_SUBDIRECTORY(test) SET (report_system_HEADERS gnc-report.h -) - -IF (BUILDING_FROM_VCS) - SET (SWIG_REPORT_SYSTEM_C ${CMAKE_CURRENT_BINARY_DIR}/swig-report-system.c) - GNC_ADD_SWIG_COMMAND (swig-report-system-c ${SWIG_REPORT_SYSTEM_C} ${CMAKE_CURRENT_SOURCE_DIR}/report-system.i ${report_system_HEADERS}) -ELSE() - SET (SWIG_REPORT_SYSTEM_C swig-report-system.c) -ENDIF() +) +# Command to generate the swig-report-system.c wrapper file +gnc_add_swig_guile_command (swig-report-system-c + SWIG_REPORT_SYSTEM_C swig-report-system.c + ${CMAKE_CURRENT_SOURCE_DIR}/report-system.i ${report_system_HEADERS} +) SET (report_system_SOURCES gncmod-report-system.c diff --git a/libgnucash/app-utils/CMakeLists.txt b/libgnucash/app-utils/CMakeLists.txt index a52bf45bf5..1c25008a50 100644 --- a/libgnucash/app-utils/CMakeLists.txt +++ b/libgnucash/app-utils/CMakeLists.txt @@ -33,18 +33,15 @@ SET (app_utils_HEADERS gnc-ui-balances.h guile-util.h option-util.h - ) +# Command to generate the swig-app-utils-guile.c wrapper file +gnc_add_swig_guile_command (swig-apputils-guile-c + SWIG_APP_UTILS_GUILE_C swig-app-utils-guile.c + ${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i +) -IF (BUILDING_FROM_VCS) - # Command to generate the swig-app-utils.c wrapper file - SET (SWIG_APP_UTILS_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-app-utils-guile.c) - GNC_ADD_SWIG_COMMAND (swig-apputils-guile-c ${SWIG_APP_UTILS_GUILE_C} ${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i) -ELSE() - SET (SWIG_APP_UTILS_GUILE_C swig-app-utils-guile.c) -ENDIF() - +# Command to generate the swig-app-utils-python.c wrapper file gnc_add_swig_python_command (swig-app-utils-python SWIG_APP_UTILS_PYTHON_C SWIG_APP_UTILS_PYTHON_PY swig-app-utils-python.c sw_app_utils.py diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt index 407c1c6989..f8dee6b0d7 100644 --- a/libgnucash/core-utils/CMakeLists.txt +++ b/libgnucash/core-utils/CMakeLists.txt @@ -2,13 +2,13 @@ ADD_SUBDIRECTORY(test) -IF (BUILDING_FROM_VCS) - SET (SWIG_CORE_UTILS_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-core-utils-guile.c) - GNC_ADD_SWIG_COMMAND (swig-core-utils-guile-c ${SWIG_CORE_UTILS_GUILE_C} ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i) -ELSE() - SET(SWIG_CORE_UTILS_GUILE_C swig-core-utils-guile.c) -ENDIF() +# Command to generate the swig-core-utils-guile.c wrapper file +gnc_add_swig_guile_command (swig-core-utils-guile-c + SWIG_CORE_UTILS_GUILE_C swig-core-utils-guile.c + ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i +) +# Command to generate the swig-core-utils-python.c wrapper file gnc_add_swig_python_command (swig-core-utils-python SWIG_CORE_UTILS_PYTHON_C SWIG_CORE_UTILS_PYTHON_PY swig-core-utils-python.c sw_core_utils.py diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt index d88d710d91..560bc38376 100644 --- a/libgnucash/engine/CMakeLists.txt +++ b/libgnucash/engine/CMakeLists.txt @@ -117,13 +117,11 @@ SET (engine_HEADERS qof-string-cache.h ) -IF (BUILDING_FROM_VCS) - # Command to generate the swig-engine.c wrapper file - SET (SWIG_ENGINE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-engine.c) - GNC_ADD_SWIG_COMMAND (swig-engine-c ${SWIG_ENGINE_C} ${CMAKE_CURRENT_SOURCE_DIR}/engine.i ${engine_HEADERS}) -ELSE() - SET (SWIG_ENGINE_C swig-engine.c) -ENDIF() +# Command to generate the swig-engine.c wrapper file +gnc_add_swig_guile_command (swig-engine-c + SWIG_ENGINE_C swig-engine.c + ${CMAKE_CURRENT_SOURCE_DIR}/engine.i ${engine_HEADERS} +) # Command to generate the iso-4217-currencies.c file SET (ISO_4217_C ${CMAKE_CURRENT_BINARY_DIR}/iso-4217-currencies.c) diff --git a/libgnucash/gnc-module/CMakeLists.txt b/libgnucash/gnc-module/CMakeLists.txt index 120a592559..c5ce2fecfb 100644 --- a/libgnucash/gnc-module/CMakeLists.txt +++ b/libgnucash/gnc-module/CMakeLists.txt @@ -2,13 +2,11 @@ ADD_SUBDIRECTORY(test) ADD_SUBDIRECTORY(example) -IF (BUILDING_FROM_VCS) - # Command to generate the swig-gnc-module.c wrapper file - SET (SWIG_GNC_MODULE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnc-module.c) - GNC_ADD_SWIG_COMMAND (swig-gnc-module-c ${SWIG_GNC_MODULE_C} ${CMAKE_CURRENT_SOURCE_DIR}/gnc-module.i) -ELSE() - SET (SWIG_GNC_MODULE_C swig-gnc-module.c) -ENDIF() +# Command to generate the swig-gnc-module.c wrapper file +gnc_add_swig_guile_command (swig-gnc-module-c + SWIG_GNC_MODULE_C swig-gnc-module.c + ${CMAKE_CURRENT_SOURCE_DIR}/gnc-module.i +) SET (gnc_module_SOURCES gnc-module.c) diff --git a/libgnucash/gnc-module/test/mod-bar/CMakeLists.txt b/libgnucash/gnc-module/test/mod-bar/CMakeLists.txt index 06763b131b..257f811600 100644 --- a/libgnucash/gnc-module/test/mod-bar/CMakeLists.txt +++ b/libgnucash/gnc-module/test/mod-bar/CMakeLists.txt @@ -1,10 +1,8 @@ -IF (BUILDING_FROM_VCS) - SET (SWIG_BAR_C ${CMAKE_CURRENT_BINARY_DIR}/swig-bar.c) - GNC_ADD_SWIG_COMMAND (swig-bar-c ${SWIG_BAR_C} ${CMAKE_CURRENT_SOURCE_DIR}/bar.i bar.h) -ELSE() - SET (SWIG_BAR_C ${CMAKE_CURRENT_SOURCE_DIR}/swig-bar.c) -ENDIF() +gnc_add_swig_guile_command (swig-bar-c + SWIG_BAR_C swig-bar.c + ${CMAKE_CURRENT_SOURCE_DIR}/bar.i bar.h +) ADD_LIBRARY(bar EXCLUDE_FROM_ALL bar.c bar.h) ADD_LIBRARY(gncmodbar EXCLUDE_FROM_ALL gnc-mod-bar.c) diff --git a/libgnucash/gnc-module/test/mod-baz/CMakeLists.txt b/libgnucash/gnc-module/test/mod-baz/CMakeLists.txt index 1a60d90023..77023740a1 100644 --- a/libgnucash/gnc-module/test/mod-baz/CMakeLists.txt +++ b/libgnucash/gnc-module/test/mod-baz/CMakeLists.txt @@ -1,10 +1,8 @@ -IF (BUILDING_FROM_VCS) - SET (SWIG_BAZ_C ${CMAKE_CURRENT_BINARY_DIR}/swig-baz.c) - GNC_ADD_SWIG_COMMAND (swig-baz-c ${SWIG_BAZ_C} ${CMAKE_CURRENT_SOURCE_DIR}/baz.i baz.h) -ELSE() - SET (SWIG_BAZ_C ${CMAKE_CURRENT_SOURCE_DIR}/swig-baz.c) -ENDIF() +gnc_add_swig_guile_command (swig-baz-c + SWIG_BAZ_C swig-baz.c + ${CMAKE_CURRENT_SOURCE_DIR}/baz.i baz.h +) ADD_LIBRARY(baz EXCLUDE_FROM_ALL baz.c baz.h) TARGET_INCLUDE_DIRECTORIES(baz PRIVATE diff --git a/libgnucash/gnc-module/test/mod-foo/CMakeLists.txt b/libgnucash/gnc-module/test/mod-foo/CMakeLists.txt index 5b6eb8c4af..4c9734e210 100644 --- a/libgnucash/gnc-module/test/mod-foo/CMakeLists.txt +++ b/libgnucash/gnc-module/test/mod-foo/CMakeLists.txt @@ -1,10 +1,8 @@ -IF (BUILDING_FROM_VCS) - SET (SWIG_FOO_C ${CMAKE_CURRENT_BINARY_DIR}/swig-foo.c) - GNC_ADD_SWIG_COMMAND (swig-foo-c ${SWIG_FOO_C} ${CMAKE_CURRENT_SOURCE_DIR}/foo.i foo.h) -ELSE() - SET (SWIG_FOO_C ${CMAKE_CURRENT_SOURCE_DIR}/swig-foo.c) -ENDIF() +gnc_add_swig_guile_command (swig-foo-c + SWIG_FOO_C swig-foo.c + ${CMAKE_CURRENT_SOURCE_DIR}/foo.i foo.h +) ADD_LIBRARY(foo EXCLUDE_FROM_ALL foo.c foo.h) ADD_LIBRARY(gncmodfoo EXCLUDE_FROM_ALL gnc-mod-foo.c)