From 993c282905b13e2f78fe7ee66815370020aab7a1 Mon Sep 17 00:00:00 2001 From: chrisbeall Date: Mon, 22 May 2017 16:23:46 -0400 Subject: [PATCH] Add build dependency to ensure cython wrapper is built after cpp library --- cmake/GtsamCythonWrap.cmake | 11 ++++++----- gtsam/CMakeLists.txt | 1 + gtsam_unstable/CMakeLists.txt | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmake/GtsamCythonWrap.cmake b/cmake/GtsamCythonWrap.cmake index 291b6a22a..1cf03e3e0 100644 --- a/cmake/GtsamCythonWrap.cmake +++ b/cmake/GtsamCythonWrap.cmake @@ -26,17 +26,18 @@ endif() # to setup.py file by cmake and used to compile the Cython module # by invoking "python setup.py build_ext --inplace" # 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 get_filename_component(module_name "${interface_header}" NAME_WE) 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}") endfunction() # 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 # Extract module path and name from interface header file name # 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}) # Set up building of mex module - add_custom_target(${module_name}_cython_wrapper ALL DEPENDS ${generated_cpp_file} ${interface_header}) - add_custom_target(wrap_${module_name}_cython_distclean + add_custom_target(${module_name}_cython_wrapper ALL DEPENDS ${generated_cpp_file} ${interface_header} ${dependencies}) + add_custom_target(wrap_${module_name}_cython_distclean COMMAND cmake -E remove_directory ${generated_files_path}) endfunction() diff --git a/gtsam/CMakeLists.txt b/gtsam/CMakeLists.txt index eb9154091..8e8302ba5 100644 --- a/gtsam/CMakeLists.txt +++ b/gtsam/CMakeLists.txt @@ -176,5 +176,6 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX) "" # extra imports "../cython/gtsam" # path to setup.py.in "${GTSAM_CYTHON_INSTALL_PATH}/gtsam" # install path + gtsam # dependencies which need to be built before the wrapper ) endif () diff --git a/gtsam_unstable/CMakeLists.txt b/gtsam_unstable/CMakeLists.txt index 7e26bca04..bcf53946c 100644 --- a/gtsam_unstable/CMakeLists.txt +++ b/gtsam_unstable/CMakeLists.txt @@ -129,6 +129,7 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX) "from gtsam.gtsam cimport *" # extra imports "../cython/gtsam_unstable" # path to setup.py.in "${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) endif ()