Fix the dependency problem where cython didn't get called when the header file is updated. Also change target gtsam_cython to cythonize_gtsam.
parent
3e8807b575
commit
0d47d273c6
|
@ -84,14 +84,18 @@ endfunction()
|
||||||
# - output_dir: The output directory
|
# - output_dir: The output directory
|
||||||
# - include_dirs: Directories to include when executing cython
|
# - include_dirs: Directories to include when executing cython
|
||||||
# - libs: Libraries to link with
|
# - libs: Libraries to link with
|
||||||
# - dependencies: Other target dependencies
|
# - interface_header: For dependency. Any update in interface header will re-trigger cythonize
|
||||||
function(cythonize target pyx_file output_lib_we output_dir include_dirs libs dependencies)
|
function(cythonize target pyx_file output_lib_we output_dir include_dirs libs interface_header dependencies)
|
||||||
get_filename_component(pyx_path "${pyx_file}" DIRECTORY)
|
get_filename_component(pyx_path "${pyx_file}" DIRECTORY)
|
||||||
get_filename_component(pyx_name "${pyx_file}" NAME_WE)
|
get_filename_component(pyx_name "${pyx_file}" NAME_WE)
|
||||||
set(generated_cpp "${output_dir}/${pyx_name}.cpp")
|
set(generated_cpp "${output_dir}/${pyx_name}.cpp")
|
||||||
|
|
||||||
set_up_required_cython_packages()
|
set_up_required_cython_packages()
|
||||||
pyx_to_cpp(${target}_pyx2cpp ${pyx_file} ${generated_cpp} "${include_dirs}")
|
pyx_to_cpp(${target}_pyx2cpp ${pyx_file} ${generated_cpp} "${include_dirs}")
|
||||||
|
|
||||||
|
# Late dependency injection, to make sure this gets called whenever the interface header is updated
|
||||||
|
# See: https://stackoverflow.com/questions/40032593/cmake-does-not-rebuild-dependent-after-prerequisite-changes
|
||||||
|
add_custom_command(OUTPUT ${generated_cpp} DEPENDS ${interface_header} APPEND)
|
||||||
if (NOT "${dependencies}" STREQUAL "")
|
if (NOT "${dependencies}" STREQUAL "")
|
||||||
add_dependencies(${target}_pyx2cpp "${dependencies}")
|
add_dependencies(${target}_pyx2cpp "${dependencies}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -130,8 +134,8 @@ function(wrap_library_cython interface_header generated_files_path extra_imports
|
||||||
|
|
||||||
message(STATUS "Cythonize and build ${module_name}.pyx")
|
message(STATUS "Cythonize and build ${module_name}.pyx")
|
||||||
get_property(include_dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
get_property(include_dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
||||||
cythonize(${module_name}_cython ${generated_pyx} ${module_name}
|
cythonize(cythonize_${module_name} ${generated_pyx} ${module_name}
|
||||||
${generated_files_path} "${include_dirs}" "${libs}" cython_wrap_${module_name}_pyx)
|
${generated_files_path} "${include_dirs}" "${libs}" ${interface_header} cython_wrap_${module_name}_pyx)
|
||||||
|
|
||||||
# distclean
|
# distclean
|
||||||
add_custom_target(wrap_${module_name}_cython_distclean
|
add_custom_target(wrap_${module_name}_cython_distclean
|
||||||
|
|
|
@ -24,7 +24,7 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX)
|
||||||
"from gtsam.gtsam cimport *" # extra imports
|
"from gtsam.gtsam cimport *" # extra imports
|
||||||
"${GTSAM_CYTHON_INSTALL_PATH}/gtsam" # install path
|
"${GTSAM_CYTHON_INSTALL_PATH}/gtsam" # install path
|
||||||
gtsam_unstable # library to link with
|
gtsam_unstable # library to link with
|
||||||
"gtsam_unstable;gtsam_unstable_header;gtsam_cython" # dependencies to be built before wrapping
|
"gtsam_unstable;gtsam_unstable_header;cythonize_gtsam" # dependencies to be built before wrapping
|
||||||
)
|
)
|
||||||
# for some reasons cython gtsam_unstable can't find gtsam/gtsam.pxd without doing this
|
# for some reasons cython gtsam_unstable can't find gtsam/gtsam.pxd without doing this
|
||||||
file(WRITE ${PROJECT_BINARY_DIR}/cython/gtsam_unstable/__init__.py "")
|
file(WRITE ${PROJECT_BINARY_DIR}/cython/gtsam_unstable/__init__.py "")
|
||||||
|
|
|
@ -19,9 +19,9 @@ message(STATUS "Cythonize and build eigency")
|
||||||
# a part of the gtsam_eigency package and generate the function call import_gtsam_igency__conversions()
|
# a part of the gtsam_eigency package and generate the function call import_gtsam_igency__conversions()
|
||||||
# in conversions_api.h correctly!!!
|
# in conversions_api.h correctly!!!
|
||||||
cythonize(cythonize_eigency_conversions "../gtsam_eigency/conversions.pyx" "conversions"
|
cythonize(cythonize_eigency_conversions "../gtsam_eigency/conversions.pyx" "conversions"
|
||||||
"${OUTPUT_DIR}" "${EIGENCY_INCLUDE_DIR}" "" "")
|
"${OUTPUT_DIR}" "${EIGENCY_INCLUDE_DIR}" "" "" "")
|
||||||
cythonize(cythonize_eigency_core "../gtsam_eigency/core.pyx" "core"
|
cythonize(cythonize_eigency_core "../gtsam_eigency/core.pyx" "core"
|
||||||
${OUTPUT_DIR} "${EIGENCY_INCLUDE_DIR}" "" "")
|
${OUTPUT_DIR} "${EIGENCY_INCLUDE_DIR}" "" "" "")
|
||||||
add_dependencies(cythonize_eigency_core cythonize_eigency_conversions)
|
add_dependencies(cythonize_eigency_core cythonize_eigency_conversions)
|
||||||
add_custom_target(cythonize_eigency)
|
add_custom_target(cythonize_eigency)
|
||||||
add_dependencies(cythonize_eigency cythonize_eigency_conversions cythonize_eigency_core)
|
add_dependencies(cythonize_eigency cythonize_eigency_conversions cythonize_eigency_core)
|
||||||
|
|
Loading…
Reference in New Issue