Add build dependency to ensure cython wrapper is built after cpp library

release/4.3a0
chrisbeall 2017-05-22 16:23:46 -04:00
parent c8dec5d8dc
commit 993c282905
3 changed files with 8 additions and 5 deletions

View File

@ -26,17 +26,18 @@ endif()
# to setup.py file by cmake and used to compile the Cython module # to setup.py file by cmake and used to compile the Cython module
# by invoking "python setup.py build_ext --inplace" # by invoking "python setup.py build_ext --inplace"
# install_path: destination to install the library # install_path: destination to install the library
function(wrap_and_install_library_cython interface_header extra_imports setup_py_in_path install_path) # dependencies: Dependencies which need to be built before the wrapper
function(wrap_and_install_library_cython interface_header extra_imports setup_py_in_path install_path dependencies)
# Paths for generated files # Paths for generated files
get_filename_component(module_name "${interface_header}" NAME_WE) get_filename_component(module_name "${interface_header}" NAME_WE)
set(generated_files_path "${PROJECT_BINARY_DIR}/cython/${module_name}") set(generated_files_path "${PROJECT_BINARY_DIR}/cython/${module_name}")
wrap_library_cython("${interface_header}" "${generated_files_path}" "${extra_imports}" "${setup_py_in_path}") wrap_library_cython("${interface_header}" "${generated_files_path}" "${extra_imports}" "${setup_py_in_path}" "${dependencies}")
install_cython_wrapped_library("${interface_header}" "${generated_files_path}" "${install_path}") install_cython_wrapped_library("${interface_header}" "${generated_files_path}" "${install_path}")
endfunction() endfunction()
# Internal function that wraps a library and compiles the wrapper # Internal function that wraps a library and compiles the wrapper
function(wrap_library_cython interface_header generated_files_path extra_imports setup_py_in_path) function(wrap_library_cython interface_header generated_files_path extra_imports setup_py_in_path dependencies)
# Wrap codegen interface # Wrap codegen interface
# Extract module path and name from interface header file name # Extract module path and name from interface header file name
# wrap requires interfacePath to be *absolute* # wrap requires interfacePath to be *absolute*
@ -73,8 +74,8 @@ function(wrap_library_cython interface_header generated_files_path extra_imports
WORKING_DIRECTORY ${generated_files_path}) WORKING_DIRECTORY ${generated_files_path})
# Set up building of mex module # Set up building of mex module
add_custom_target(${module_name}_cython_wrapper ALL DEPENDS ${generated_cpp_file} ${interface_header}) add_custom_target(${module_name}_cython_wrapper ALL DEPENDS ${generated_cpp_file} ${interface_header} ${dependencies})
add_custom_target(wrap_${module_name}_cython_distclean add_custom_target(wrap_${module_name}_cython_distclean
COMMAND cmake -E remove_directory ${generated_files_path}) COMMAND cmake -E remove_directory ${generated_files_path})
endfunction() endfunction()

View File

@ -176,5 +176,6 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX)
"" # extra imports "" # extra imports
"../cython/gtsam" # path to setup.py.in "../cython/gtsam" # path to setup.py.in
"${GTSAM_CYTHON_INSTALL_PATH}/gtsam" # install path "${GTSAM_CYTHON_INSTALL_PATH}/gtsam" # install path
gtsam # dependencies which need to be built before the wrapper
) )
endif () endif ()

View File

@ -129,6 +129,7 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX)
"from gtsam.gtsam cimport *" # extra imports "from gtsam.gtsam cimport *" # extra imports
"../cython/gtsam_unstable" # path to setup.py.in "../cython/gtsam_unstable" # path to setup.py.in
"${GTSAM_CYTHON_INSTALL_PATH}/gtsam" # install path "${GTSAM_CYTHON_INSTALL_PATH}/gtsam" # install path
gtsam_unstable # dependencies which need to be built before the wrapper
) )
add_dependencies(gtsam_unstable_cython_wrapper gtsam_cython_wrapper) add_dependencies(gtsam_unstable_cython_wrapper gtsam_cython_wrapper)
endif () endif ()