Create a proper target to generate python/gtsam/_libgtsam_python.so in the build directory

release/4.3a0
Ellon Mendes 2015-12-02 13:27:20 +01:00
parent 4671b03e74
commit 81a1fe1c3a
1 changed files with 8 additions and 5 deletions

View File

@ -22,8 +22,11 @@ set_target_properties(${moduleName}_python PROPERTIES
target_link_libraries(${moduleName}_python ${Boost_PYTHON${BOOST_PYTHON_VERSION_SUFFIX_UPPERCASE}_LIBRARY} ${PYTHON_LIBRARY} ${gtsamLib}) #temp
# Cause the library to be output in the correct directory.
add_custom_command(TARGET ${moduleName}_python
POST_BUILD
COMMAND cp -v $<TARGET_FILE:${moduleName}_python> ${CMAKE_BINARY_DIR}/python/gtsam/_$<TARGET_FILE_NAME:${moduleName}_python>
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Copying library files to python directory" )
# 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)