also use the new cythonization mechanism for gtsam
parent
b4aee31b76
commit
07574de9b0
|
@ -115,39 +115,24 @@ function(wrap_library_cython interface_header generated_files_path extra_imports
|
||||||
get_filename_component(module_path "${interface_header}" PATH)
|
get_filename_component(module_path "${interface_header}" PATH)
|
||||||
get_filename_component(module_name "${interface_header}" NAME_WE)
|
get_filename_component(module_name "${interface_header}" NAME_WE)
|
||||||
|
|
||||||
set(generated_cpp_file "${generated_files_path}/${module_name}.cpp")
|
# Wrap module to Cython pyx
|
||||||
|
message(STATUS "Cython wrapper generating ${module_name}.pyx")
|
||||||
message(STATUS "Building wrap module ${module_name}")
|
set(generated_pyx "${generated_files_path}/${module_name}.pyx")
|
||||||
|
|
||||||
# Set up generation of module source file
|
|
||||||
file(MAKE_DIRECTORY "${generated_files_path}")
|
file(MAKE_DIRECTORY "${generated_files_path}")
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${generated_cpp_file}
|
OUTPUT ${generated_pyx}
|
||||||
DEPENDS ${interface_header} wrap
|
DEPENDS ${interface_header} wrap
|
||||||
COMMAND
|
COMMAND
|
||||||
wrap --cython
|
wrap --cython ${module_path} ${module_name} ${generated_files_path} "${extra_imports}"
|
||||||
${module_path}
|
|
||||||
${module_name}
|
|
||||||
${generated_files_path}
|
|
||||||
"${extra_imports}"
|
|
||||||
&& cython --cplus -I. "${generated_files_path}/${module_name}.pyx"
|
|
||||||
VERBATIM
|
VERBATIM
|
||||||
WORKING_DIRECTORY ${generated_files_path}/../)
|
WORKING_DIRECTORY ${generated_files_path}/../)
|
||||||
add_custom_target(${module_name}_cython_wrapper ALL DEPENDS ${generated_cpp_file} ${interface_header} ${dependencies})
|
add_custom_target(cython_wrap_${module_name}_pyx ALL DEPENDS ${generated_pyx})
|
||||||
|
add_dependencies(cython_wrap_${module_name}_pyx ${dependencies})
|
||||||
|
|
||||||
# Set up building of cython module
|
message(STATUS "Cythonize and build ${module_name}.pyx")
|
||||||
find_package(PythonLibs 2.7 REQUIRED)
|
get_property(include_dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
||||||
include_directories(${PYTHON_INCLUDE_DIRS})
|
cythonize(${module_name}_cython ${generated_pyx} ${module_name}
|
||||||
find_package(Eigency REQUIRED)
|
${generated_files_path} "${include_dirs}" "${libs}" cython_wrap_${module_name}_pyx)
|
||||||
include_directories(${EIGENCY_INCLUDE_DIRS})
|
|
||||||
find_package(NumPy REQUIRED)
|
|
||||||
include_directories(${NUMPY_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
add_library(${module_name}_cython MODULE ${generated_cpp_file})
|
|
||||||
set_target_properties(${module_name}_cython PROPERTIES LINK_FLAGS "-undefined dynamic_lookup"
|
|
||||||
OUTPUT_NAME ${module_name} PREFIX "" LIBRARY_OUTPUT_DIRECTORY ${generated_files_path})
|
|
||||||
target_link_libraries(${module_name}_cython ${libs})
|
|
||||||
add_dependencies(${module_name}_cython ${module_name}_cython_wrapper)
|
|
||||||
|
|
||||||
# distclean
|
# distclean
|
||||||
add_custom_target(wrap_${module_name}_cython_distclean
|
add_custom_target(wrap_${module_name}_cython_distclean
|
||||||
|
|
Loading…
Reference in New Issue