2013-11-15 14:59:02 +08:00
|
|
|
|
2015-11-19 21:59:30 +08:00
|
|
|
# get subdirectories list
|
2015-11-26 01:21:10 +08:00
|
|
|
subdirlist(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
|
2013-11-15 14:59:02 +08:00
|
|
|
|
2015-11-19 21:59:30 +08:00
|
|
|
# get the sources needed to compile gtsam python module
|
2015-11-26 01:21:10 +08:00
|
|
|
set(gtsam_python_srcs "")
|
|
|
|
foreach(subdir ${SUBDIRS})
|
2015-11-19 21:59:30 +08:00
|
|
|
file(GLOB ${subdir}_src "${subdir}/*.cpp")
|
2015-11-26 01:21:10 +08:00
|
|
|
list(APPEND gtsam_python_srcs ${${subdir}_src})
|
|
|
|
endforeach()
|
2013-11-15 14:59:02 +08:00
|
|
|
|
2015-11-19 21:59:30 +08:00
|
|
|
# Create the library
|
|
|
|
set(moduleName gtsam)
|
|
|
|
set(gtsamLib gtsam)
|
|
|
|
add_library(${moduleName}_python SHARED exportgtsam.cpp ${gtsam_python_srcs})
|
2013-11-15 14:59:02 +08:00
|
|
|
|
2015-11-19 21:59:30 +08:00
|
|
|
set_target_properties(${moduleName}_python PROPERTIES
|
|
|
|
OUTPUT_NAME ${moduleName}_python
|
2015-12-01 23:53:33 +08:00
|
|
|
SKIP_BUILD_RPATH TRUE
|
2015-11-19 21:59:30 +08:00
|
|
|
CLEAN_DIRECT_OUTPUT 1)
|
2013-11-15 14:59:02 +08:00
|
|
|
|
2015-12-01 21:11:39 +08:00
|
|
|
target_link_libraries(${moduleName}_python ${Boost_PYTHON${BOOST_PYTHON_VERSION_SUFFIX_UPPERCASE}_LIBRARY} ${PYTHON_LIBRARY} ${gtsamLib}) #temp
|
2015-11-19 21:59:30 +08:00
|
|
|
|
|
|
|
# Cause the library to be output in the correct directory.
|
2015-12-02 20:27:20 +08:00
|
|
|
# TODO: Change below to work on different systems (currently works only with Linux)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_BINARY_DIR}/python/gtsam/_libgtsam_python.so
|
|
|
|
DEPENDS gtsam_python
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${moduleName}_python> ${CMAKE_BINARY_DIR}/python/gtsam/_$<TARGET_FILE_NAME:${moduleName}_python>
|
|
|
|
COMMENT "Copying extension module to python/gtsam/_libgtsam_python.so"
|
|
|
|
)
|
|
|
|
add_custom_target(copy_gtsam_python_module ALL DEPENDS ${CMAKE_BINARY_DIR}/python/gtsam/_libgtsam_python.so)
|