mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
core-utils - make the swig generated source file dependent on the core-utils headers
That should trigger a regeneration of these swig sources if any of the header files change. This is done via a small macro that can be reused for other wrappers as well. Note cmake 3.15 introduces a 'FILTER' generator expression that might allow us to do something like the following: $<FILTER:$<TARGET_PROPERTY:baselib,SOURCES>,INCLUDE,"*.h[pp]?$"> I toyed briefly with that idea but it currently has two issues: 1. 3.15 is newer than our current minimum cmake requirement, so we can't depend in that feature yet. 2. the sources are relative to *their* source directory, which is different from the one in which the wrappers are generated So they should still be properly transformed into absolute paths
This commit is contained in:
parent
a1898daf6c
commit
a6b7eecd81
@ -1,9 +1,12 @@
|
||||
add_subdirectory(test)
|
||||
|
||||
# Command to generate the swig-core-utils-guile.c wrapper file
|
||||
gnc_swig_extract_header_files (gnc-core-utils CORE_UTILS_HEADERS)
|
||||
gnc_add_swig_guile_command (swig-core-utils-guile-c
|
||||
SWIG_CORE_UTILS_GUILE_C swig-core-utils-guile.c
|
||||
${CMAKE_SOURCE_DIR}/bindings/core-utils.i ${CMAKE_SOURCE_DIR}/libgnucash/core-utils
|
||||
${CMAKE_SOURCE_DIR}/bindings/core-utils.i
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/core-utils
|
||||
${CORE_UTILS_HEADERS}
|
||||
)
|
||||
|
||||
set(guile_HEADERS
|
||||
|
@ -47,10 +47,12 @@ gnc_add_swig_python_command (swig-gnucash-core
|
||||
)
|
||||
|
||||
# Command to generate the swig-core-utils-python.c wrapper file
|
||||
gnc_swig_extract_header_files (gnc-core-utils CORE_UTILS_HEADERS)
|
||||
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
|
||||
${CMAKE_SOURCE_DIR}/bindings/core-utils.i ${CMAKE_SOURCE_DIR}/libgnucash/core-utils
|
||||
${CORE_UTILS_HEADERS}
|
||||
)
|
||||
|
||||
if(WITH_PYTHON)
|
||||
|
@ -90,3 +90,25 @@ macro (gnc_add_swig_python_command _target _out_var _py_out_var _output _py_outp
|
||||
)
|
||||
add_custom_target(${_target} ALL DEPENDS ${outfile} ${py_outfile} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${_input} ${ARGN})
|
||||
endmacro()
|
||||
|
||||
|
||||
# The swig wrappers need to know the header files ("the interface")
|
||||
# for the library they are wrapping.
|
||||
# We can extract those from the target's SOURCES property
|
||||
# Using a few ordinary cmake commands
|
||||
macro (gnc_swig_extract_header_files _target _variable)
|
||||
set(${_variable} "")
|
||||
get_target_property(_headers ${_target} SOURCES)
|
||||
if(_headers)
|
||||
list(FILTER _headers INCLUDE REGEX ".*[.]h(pp)?$")
|
||||
get_target_property(_srcdir ${_target} SOURCE_DIR)
|
||||
foreach (_header ${_headers})
|
||||
if(NOT IS_ABSOLUTE "${_header}")
|
||||
set(_header_abs "${_srcdir}/${_header}")
|
||||
else()
|
||||
set(_header_abs "${_header}")
|
||||
endif()
|
||||
list (APPEND ${_variable} "${_header_abs}")
|
||||
endforeach ()
|
||||
endif()
|
||||
endmacro()
|
||||
|
Loading…
Reference in New Issue
Block a user