mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Allow to pass include directories to the add_swig_xyz commands
This will be needed when the wrappers no longer live in the same directory as the objects they are wrapping.
This commit is contained in:
@@ -10,18 +10,35 @@
|
||||
# - _out_var will be set to the full path to the generated wrapper file
|
||||
# - _output is the name of the wrapper file to generate
|
||||
# - _input is the swig interface file (*.i) to generate this wrapper from
|
||||
# - _include_dirs is an optional list of include directories to pass to the swig command
|
||||
# For guile two directories are always passed by default:
|
||||
# ${CMAKE_SOURCE_DIR}/common and ${CMAKE_SOURCE_DIR}/libgnucash/engine
|
||||
# Any additional parameters will be used as dependencies for this wrapper target
|
||||
macro (gnc_add_swig_guile_command _target _out_var _output _input)
|
||||
macro (gnc_add_swig_guile_command _target _out_var _output _input _include_dirs)
|
||||
|
||||
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 (DEFAULT_SWIG_GUILE_FLAGS
|
||||
-guile -Linkage module
|
||||
${SWIG_ARGS}
|
||||
)
|
||||
set (DEFAULT_SWIG_GUILE_C_INCLUDES
|
||||
${CMAKE_SOURCE_DIR}/common
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/engine
|
||||
)
|
||||
set (GUILE_SWIG_FLAGS ${DEFAULT_SWIG_GUILE_FLAGS})
|
||||
foreach (dir ${DEFAULT_SWIG_GUILE_C_INCLUDES} ${_include_dirs})
|
||||
list (APPEND GUILE_SWIG_FLAGS "-I${dir}")
|
||||
endforeach (dir)
|
||||
|
||||
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}
|
||||
COMMAND ${SWIG_EXECUTABLE} ${GUILE_SWIG_FLAGS} -o ${outfile} ${_input}
|
||||
)
|
||||
add_custom_target(${_target} DEPENDS ${outfile})
|
||||
endmacro (gnc_add_swig_guile_command)
|
||||
@@ -36,8 +53,12 @@ endmacro (gnc_add_swig_guile_command)
|
||||
# - _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
|
||||
# - _include_dirs is an optional list of include directories to pass to the swig command
|
||||
# For python four directories are always passed by default:
|
||||
# ${GLIB2_INCLUDE_DIRS}, ${CMAKE_SOURCE_DIR}/common,
|
||||
# ${CMAKE_SOURCE_DIR}/libgnucash/app-utils and ${CMAKE_SOURCE_DIR}/libgnucash/engine
|
||||
# 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)
|
||||
macro (gnc_add_swig_python_command _target _out_var _py_out_var _output _py_output _input _include_dirs)
|
||||
|
||||
set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(SW_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
|
||||
@@ -60,7 +81,7 @@ macro (gnc_add_swig_python_command _target _out_var _py_out_var _output _py_outp
|
||||
)
|
||||
|
||||
set (PYTHON_SWIG_FLAGS ${DEFAULT_SWIG_PYTHON_FLAGS})
|
||||
foreach (dir ${DEFAULT_SWIG_PYTHON_C_INCLUDES})
|
||||
foreach (dir ${DEFAULT_SWIG_PYTHON_C_INCLUDES} ${_include_dirs})
|
||||
list (APPEND PYTHON_SWIG_FLAGS "-I${dir}")
|
||||
endforeach (dir)
|
||||
add_custom_command(OUTPUT ${outfile} ${py_outfile}
|
||||
|
||||
@@ -30,14 +30,14 @@ 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}
|
||||
${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
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i ""
|
||||
)
|
||||
|
||||
add_library(test-core-guile ${SWIG_UNITTEST_SUPPORT_GUILE_C})
|
||||
|
||||
Reference in New Issue
Block a user