Merged in feature/cython_wrapper_build_fixes (pull request #294)
Feature/cython wrapper build fixes Approved-by: Duy-Nguyen Ta <thduynguyen@gmail.com>release/4.3a0
commit
f7f5e5cd26
|
@ -145,3 +145,30 @@ function(install_cython_scripts source_directory dest_directory patterns)
|
|||
|
||||
endfunction()
|
||||
|
||||
# Helper function to install specific files and handle multiple build types where the scripts
|
||||
# should be installed to all build type toolboxes
|
||||
#
|
||||
# Arguments:
|
||||
# source_files: The source files to be installed.
|
||||
# dest_directory: The destination directory to install to.
|
||||
function(install_cython_files source_files dest_directory)
|
||||
|
||||
if(GTSAM_BUILD_TYPE_POSTFIXES)
|
||||
foreach(build_type ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER "${build_type}" build_type_upper)
|
||||
if(${build_type_upper} STREQUAL "RELEASE")
|
||||
set(build_type_tag "") # Don't create release mode tag on installed directory
|
||||
else()
|
||||
set(build_type_tag "${build_type}")
|
||||
endif()
|
||||
# Split up filename to strip trailing '/' in GTSAM_CYTHON_INSTALL_PATH if there is one
|
||||
get_filename_component(location "${dest_directory}" PATH)
|
||||
get_filename_component(name "${dest_directory}" NAME)
|
||||
install(FILES "${source_files}" DESTINATION "${location}/${name}${build_type_tag}")
|
||||
endforeach()
|
||||
else()
|
||||
install(FILES "${source_files}" DESTINATION "${dest_directory}")
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
|
|
|
@ -2,3 +2,14 @@
|
|||
include(GtsamCythonWrap)
|
||||
# install scripts and tests
|
||||
install_cython_scripts("${CMAKE_SOURCE_DIR}/cython/gtsam" "${GTSAM_CYTHON_INSTALL_PATH}" "*.py")
|
||||
|
||||
|
||||
# generate __init__.py into build folder (configured with or without gtsam_unstable import line)
|
||||
# This also makes the build/cython/gtsam folder a python package, so gtsam can be found while wrapping gtsam_unstable
|
||||
if(GTSAM_BUILD_UNSTABLE)
|
||||
set(GTSAM_UNSTABLE_IMPORT "from gtsam_unstable import *")
|
||||
endif()
|
||||
configure_file(${CMAKE_SOURCE_DIR}/cython/gtsam/__init__.py.in ${PROJECT_BINARY_DIR}/cython/gtsam/__init__.py)
|
||||
|
||||
# Install the custom-generated __init__.py
|
||||
install_cython_files("${PROJECT_BINARY_DIR}/cython/gtsam/__init__.py" "${GTSAM_CYTHON_INSTALL_PATH}/gtsam")
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
from gtsam import *
|
||||
from gtsam_unstable import *
|
|
@ -0,0 +1,2 @@
|
|||
from gtsam import *
|
||||
${GTSAM_UNSTABLE_IMPORT}
|
|
@ -20,7 +20,8 @@ setup(
|
|||
"${Boost_INCLUDE_DIR}"
|
||||
] + eigency.get_includes(include_eigen=False),
|
||||
libraries=['gtsam', 'gtsam_unstable'],
|
||||
library_dirs=["${GTSAM_DIR}/../../"],
|
||||
library_dirs = ["${CMAKE_BINARY_DIR}/gtsam",
|
||||
"${CMAKE_BINARY_DIR}/gtsam_unstable"],
|
||||
language="c++",
|
||||
extra_compile_args="${CMAKE_CXX_FLAGS}".split(),
|
||||
extra_link_args="${CMAKE_SHARED_LINKER_FLAGS}".split()))
|
||||
|
|
|
@ -131,9 +131,6 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX)
|
|||
"${GTSAM_CYTHON_INSTALL_PATH}/gtsam" # install path
|
||||
)
|
||||
add_dependencies(gtsam_unstable_cython_wrapper gtsam_cython_wrapper)
|
||||
# making the build/cython/gtsam folder a python package, so gtsam can be found while wrapping gtsam_unstable
|
||||
add_custom_target(copy_gtsam_init COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/cython/gtsam/__init__.py" "${CMAKE_BINARY_DIR}/cython/gtsam")
|
||||
add_dependencies(gtsam_unstable_cython_wrapper copy_gtsam_init)
|
||||
endif ()
|
||||
|
||||
# Build examples
|
||||
|
|
Loading…
Reference in New Issue