Fix cython build when GTSAM_BUILD_TYPE_POSTFIXES is enabled. And fix cython build when gtsam is built as part of a larger project, i.e. it is not the top-level project.

release/4.3a0
cbeall 2017-04-07 18:43:08 -07:00
parent f7f5e5cd26
commit 265e8773ba
4 changed files with 15 additions and 7 deletions

View File

@ -48,6 +48,14 @@ function(wrap_library_cython interface_header generated_files_path extra_imports
message(STATUS "Building wrap module ${module_name}")
# Get build type postfix - gtsam_library_postfix is used in setup.py.in
# to link cythonized library to appropriate version of gtsam library
set(gtsam_library_postfix "")
if(GTSAM_BUILD_TYPE_POSTFIXES)
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type_upper)
set(gtsam_library_postfix ${CMAKE_${build_type_upper}_POSTFIX})
endif()
# Set up generation of module source file
file(MAKE_DIRECTORY "${generated_files_path}")
configure_file(${setup_py_in_path}/setup.py.in ${generated_files_path}/setup.py)

View File

@ -1,7 +1,7 @@
# Install cython components
include(GtsamCythonWrap)
# install scripts and tests
install_cython_scripts("${CMAKE_SOURCE_DIR}/cython/gtsam" "${GTSAM_CYTHON_INSTALL_PATH}" "*.py")
install_cython_scripts("${PROJECT_SOURCE_DIR}/cython/gtsam" "${GTSAM_CYTHON_INSTALL_PATH}" "*.py")
# generate __init__.py into build folder (configured with or without gtsam_unstable import line)
@ -9,7 +9,7 @@ install_cython_scripts("${CMAKE_SOURCE_DIR}/cython/gtsam" "${GTSAM_CYTHON_INSTAL
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)
configure_file(${PROJECT_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")

View File

@ -12,12 +12,12 @@ setup(
ext_modules = cythonize(Extension(
"gtsam",
sources=["gtsam.pyx"],
include_dirs = ["${CMAKE_SOURCE_DIR}", "${CMAKE_BINARY_DIR}",
"${CMAKE_SOURCE_DIR}/gtsam/3rdparty/Eigen",
include_dirs = ["${PROJECT_SOURCE_DIR}", "${CMAKE_BINARY_DIR}",
"${PROJECT_SOURCE_DIR}/gtsam/3rdparty/Eigen",
"${Boost_INCLUDE_DIR}"
] + eigency.get_includes(include_eigen=False),
libraries = ['gtsam'],
library_dirs = ["${CMAKE_BINARY_DIR}/gtsam"],
libraries = ['gtsam${gtsam_library_postfix}'],
library_dirs = ["${CMAKE_CURRENT_BINARY_DIR}"],
language="c++",
extra_compile_args="${CMAKE_CXX_FLAGS}".split(),
extra_link_args="${CMAKE_SHARED_LINKER_FLAGS}".split()))

View File

@ -19,7 +19,7 @@ setup(
"${CMAKE_SOURCE_DIR}/gtsam/3rdparty/Eigen",
"${Boost_INCLUDE_DIR}"
] + eigency.get_includes(include_eigen=False),
libraries=['gtsam', 'gtsam_unstable'],
libraries=['gtsam${gtsam_library_postfix}', 'gtsam_unstable${gtsam_library_postfix}'],
library_dirs = ["${CMAKE_BINARY_DIR}/gtsam",
"${CMAKE_BINARY_DIR}/gtsam_unstable"],
language="c++",