eigency --> clonedEigency. Fixing bugs and improve eigency build.
parent
8283ff7b82
commit
742097aed0
|
@ -21,7 +21,7 @@ install(FILES
|
|||
GtsamCythonWrap.cmake
|
||||
GtsamTesting.cmake
|
||||
FindCython.cmake
|
||||
FindEigency.cmake
|
||||
FindClonedEigency.cmake
|
||||
FindNumPy.cmake
|
||||
README.html
|
||||
DESTINATION "${SCRIPT_INSTALL_DIR}/GTSAMCMakeTools")
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
# Find the cloned version of eigency built and installed by gtsam
|
||||
#
|
||||
# This code sets the following variables:
|
||||
#
|
||||
# CLONEDEIGENCY_FOUND
|
||||
# CLONEDEIGENCY_INCLUDE_DIRS
|
||||
#
|
||||
|
||||
# Find python
|
||||
find_package( PythonInterp )
|
||||
if ( PYTHONINTERP_FOUND )
|
||||
execute_process( COMMAND "${PYTHON_EXECUTABLE}" "-c"
|
||||
"import clonedEigency; includes=clonedEigency.get_includes(include_eigen=False); print includes[0], ';', includes[1]"
|
||||
RESULT_VARIABLE RESULT
|
||||
OUTPUT_VARIABLE CLONEDEIGENCY_INCLUDE_DIRS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif ()
|
||||
|
||||
include( FindPackageHandleStandardArgs )
|
||||
find_package_handle_standard_args(ClonedEigency
|
||||
FOUND_VAR
|
||||
CLONEDEIGENCY_FOUND
|
||||
REQUIRED_VARS
|
||||
CLONEDEIGENCY_INCLUDE_DIRS
|
||||
)
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
# Find Eigency
|
||||
#
|
||||
# This code sets the following variables:
|
||||
#
|
||||
# EIGENCY_FOUND
|
||||
# EIGENCY_INCLUDE_DIRS
|
||||
#
|
||||
|
||||
# Find python
|
||||
find_package( PythonInterp )
|
||||
if ( PYTHONINTERP_FOUND )
|
||||
execute_process( COMMAND "${PYTHON_EXECUTABLE}" "-c"
|
||||
"import eigency; includes=eigency.get_includes(include_eigen=False); print includes[0], ';', includes[1]"
|
||||
RESULT_VARIABLE RESULT
|
||||
OUTPUT_VARIABLE EIGENCY_INCLUDE_DIRS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif ()
|
||||
|
||||
include( FindPackageHandleStandardArgs )
|
||||
find_package_handle_standard_args(Eigency
|
||||
FOUND_VAR
|
||||
EIGENCY_FOUND
|
||||
REQUIRED_VARS
|
||||
EIGENCY_INCLUDE_DIRS
|
||||
)
|
||||
|
|
@ -58,7 +58,7 @@ function(pyx_to_cpp target pyx_file generated_cpp include_dirs)
|
|||
add_custom_command(
|
||||
OUTPUT ${generated_cpp}
|
||||
COMMAND
|
||||
cython --cplus ${includes_for_cython} ${pyx_file} -o ${generated_cpp}
|
||||
cython -v --cplus ${includes_for_cython} ${pyx_file} -o ${generated_cpp}
|
||||
VERBATIM)
|
||||
add_custom_target(${target} ALL DEPENDS ${generated_cpp})
|
||||
endfunction()
|
||||
|
|
|
@ -3,10 +3,9 @@ include(GtsamCythonWrap)
|
|||
|
||||
# Create the cython toolbox for the gtsam library
|
||||
if (GTSAM_INSTALL_CYTHON_TOOLBOX)
|
||||
# build and include eigency
|
||||
add_subdirectory(eigency)
|
||||
include_directories(eigency)
|
||||
file(COPY eigency DESTINATION ".") # so eigency's cython headers can be found when cythonizing gtsam
|
||||
# build and include the eigency version of eigency
|
||||
add_subdirectory(clonedEigency)
|
||||
include_directories(${PROJECT_BINARY_DIR}/cython/clonedEigency)
|
||||
|
||||
# wrap gtsam
|
||||
add_custom_target(gtsam_header DEPENDS "../gtsam.h")
|
||||
|
@ -14,7 +13,7 @@ if (GTSAM_INSTALL_CYTHON_TOOLBOX)
|
|||
"" # extra imports
|
||||
"${GTSAM_CYTHON_INSTALL_PATH}/gtsam" # install path
|
||||
gtsam # library to link with
|
||||
"wrap;gtsam;gtsam_header" # dependencies which need to be built before wrapping
|
||||
"wrap;cythonize_eigency;gtsam;gtsam_header" # dependencies which need to be built before wrapping
|
||||
)
|
||||
|
||||
# wrap gtsam_unstable
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
include(GtsamCythonWrap)
|
||||
|
||||
# Copy eigency's sources to the build folder
|
||||
# so that the cython-generated header "conversions_api.h" can be found when cythonizing eigency's core
|
||||
# and eigency's cython pxd headers can be found when cythonizing gtsam
|
||||
file(COPY "." DESTINATION ".")
|
||||
set(OUTPUT_DIR "${PROJECT_BINARY_DIR}/cython/clonedEigency")
|
||||
set(EIGENCY_INCLUDE_DIR ${OUTPUT_DIR})
|
||||
|
||||
# This is to make the build/cython/clonedEigency folder a python package
|
||||
configure_file(__init__.py.in ${PROJECT_BINARY_DIR}/cython/clonedEigency/__init__.py)
|
||||
|
||||
# include eigency headers
|
||||
include_directories(${EIGENCY_INCLUDE_DIR})
|
||||
|
||||
# Cythonize and build eigency
|
||||
message(STATUS "Cythonize and build eigency")
|
||||
# Important trick: use "../clonedEigency/conversions.pyx" to let cython know that the conversions module is
|
||||
# a part of the clonedEigency package and generate the function call import_clonedEigency__conversions()
|
||||
# in conversions_api.h correctly!!!
|
||||
cythonize(cythonize_eigency_conversions "../clonedEigency/conversions.pyx" "conversions"
|
||||
"${OUTPUT_DIR}" "${EIGENCY_INCLUDE_DIR}" "" "")
|
||||
cythonize(cythonize_eigency_core "../clonedEigency/core.pyx" "core"
|
||||
${OUTPUT_DIR} "${EIGENCY_INCLUDE_DIR}" "" "")
|
||||
add_dependencies(cythonize_eigency_core cythonize_eigency_conversions)
|
||||
add_custom_target(cythonize_eigency)
|
||||
add_dependencies(cythonize_eigency cythonize_eigency_conversions cythonize_eigency_core)
|
||||
|
||||
# install
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${GTSAM_CYTHON_INSTALL_PATH})
|
||||
install(TARGETS cythonize_eigency_core cythonize_eigency_conversions
|
||||
DESTINATION "${GTSAM_CYTHON_INSTALL_PATH}/clonedEigency")
|
||||
install(FILES "${OUTPUT_DIR}/conversions_api.h" DESTINATION ${GTSAM_CYTHON_INSTALL_PATH}/clonedEigency)
|
||||
configure_file(__init__.py.in ${GTSAM_CYTHON_INSTALL_PATH}/clonedEigency/__init__.py)
|
|
@ -215,7 +215,7 @@ inline PyArrayObject *_ndarray_copy<std::complex<float> >(const std::complex<flo
|
|||
|
||||
template <typename Derived>
|
||||
inline PyArrayObject *ndarray(Eigen::PlainObjectBase<Derived> &m) {
|
||||
import_eigency__conversions();
|
||||
import_clonedEigency__conversions();
|
||||
return _ndarray_view(m.data(), m.rows(), m.cols(), m.IsRowMajor);
|
||||
}
|
||||
// If C++11 is available, check if m is an r-value reference, in
|
||||
|
@ -223,56 +223,56 @@ inline PyArrayObject *ndarray(Eigen::PlainObjectBase<Derived> &m) {
|
|||
#if __cplusplus >= 201103L
|
||||
template <typename Derived>
|
||||
inline PyArrayObject *ndarray(Eigen::PlainObjectBase<Derived> &&m) {
|
||||
import_eigency__conversions();
|
||||
import_clonedEigency__conversions();
|
||||
return _ndarray_copy(m.data(), m.rows(), m.cols(), m.IsRowMajor);
|
||||
}
|
||||
#endif
|
||||
template <typename Derived>
|
||||
inline PyArrayObject *ndarray(const Eigen::PlainObjectBase<Derived> &m) {
|
||||
import_eigency__conversions();
|
||||
import_clonedEigency__conversions();
|
||||
return _ndarray_copy(m.data(), m.rows(), m.cols(), m.IsRowMajor);
|
||||
}
|
||||
template <typename Derived>
|
||||
inline PyArrayObject *ndarray_view(Eigen::PlainObjectBase<Derived> &m) {
|
||||
import_eigency__conversions();
|
||||
import_clonedEigency__conversions();
|
||||
return _ndarray_view(m.data(), m.rows(), m.cols(), m.IsRowMajor);
|
||||
}
|
||||
template <typename Derived>
|
||||
inline PyArrayObject *ndarray_view(const Eigen::PlainObjectBase<Derived> &m) {
|
||||
import_eigency__conversions();
|
||||
import_clonedEigency__conversions();
|
||||
return _ndarray_view(const_cast<typename Derived::Scalar*>(m.data()), m.rows(), m.cols(), m.IsRowMajor);
|
||||
}
|
||||
template <typename Derived>
|
||||
inline PyArrayObject *ndarray_copy(const Eigen::PlainObjectBase<Derived> &m) {
|
||||
import_eigency__conversions();
|
||||
import_clonedEigency__conversions();
|
||||
return _ndarray_copy(m.data(), m.rows(), m.cols(), m.IsRowMajor);
|
||||
}
|
||||
|
||||
template <typename Derived, int MapOptions, typename Stride>
|
||||
inline PyArrayObject *ndarray(Eigen::Map<Derived, MapOptions, Stride> &m) {
|
||||
import_eigency__conversions();
|
||||
import_clonedEigency__conversions();
|
||||
return _ndarray_view(m.data(), m.rows(), m.cols(), m.IsRowMajor, m.outerStride(), m.innerStride());
|
||||
}
|
||||
template <typename Derived, int MapOptions, typename Stride>
|
||||
inline PyArrayObject *ndarray(const Eigen::Map<Derived, MapOptions, Stride> &m) {
|
||||
import_eigency__conversions();
|
||||
import_clonedEigency__conversions();
|
||||
// Since this is a map, we assume that ownership is correctly taken care
|
||||
// of, and we avoid taking a copy
|
||||
return _ndarray_view(const_cast<typename Derived::Scalar*>(m.data()), m.rows(), m.cols(), m.IsRowMajor, m.outerStride(), m.innerStride());
|
||||
}
|
||||
template <typename Derived, int MapOptions, typename Stride>
|
||||
inline PyArrayObject *ndarray_view(Eigen::Map<Derived, MapOptions, Stride> &m) {
|
||||
import_eigency__conversions();
|
||||
import_clonedEigency__conversions();
|
||||
return _ndarray_view(m.data(), m.rows(), m.cols(), m.IsRowMajor, m.outerStride(), m.innerStride());
|
||||
}
|
||||
template <typename Derived, int MapOptions, typename Stride>
|
||||
inline PyArrayObject *ndarray_view(const Eigen::Map<Derived, MapOptions, Stride> &m) {
|
||||
import_eigency__conversions();
|
||||
import_clonedEigency__conversions();
|
||||
return _ndarray_view(const_cast<typename Derived::Scalar*>(m.data()), m.rows(), m.cols(), m.IsRowMajor, m.outerStride(), m.innerStride());
|
||||
}
|
||||
template <typename Derived, int MapOptions, typename Stride>
|
||||
inline PyArrayObject *ndarray_copy(const Eigen::Map<Derived, MapOptions, Stride> &m) {
|
||||
import_eigency__conversions();
|
||||
import_clonedEigency__conversions();
|
||||
return _ndarray_copy(m.data(), m.rows(), m.cols(), m.IsRowMajor, m.outerStride(), m.innerStride());
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
include(GtsamCythonWrap)
|
||||
|
||||
# include eigency headers
|
||||
set(EIGENCY_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${EIGENCY_INCLUDE_DIR})
|
||||
|
||||
# cythonize and build eigency
|
||||
message(STATUS "Cythonize and build eigency")
|
||||
cythonize(cythonize_eigency_core "${CMAKE_CURRENT_SOURCE_DIR}/core.pyx" "core"
|
||||
"${PROJECT_BINARY_DIR}/cython/eigency" "${EIGENCY_INCLUDE_DIR}" "" "")
|
||||
cythonize(cythonize_eigency_conversions "${CMAKE_CURRENT_SOURCE_DIR}/conversions.pyx" "conversions"
|
||||
"${PROJECT_BINARY_DIR}/cython/eigency" "${EIGENCY_INCLUDE_DIR}" "" "")
|
||||
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${GTSAM_CYTHON_INSTALL_PATH})
|
||||
install(TARGETS cythonize_eigency_core cythonize_eigency_conversions
|
||||
DESTINATION ${GTSAM_CYTHON_INSTALL_PATH}/eigency)
|
||||
configure_file(__init__.py.in ${GTSAM_CYTHON_INSTALL_PATH}/eigency/__init__.py)
|
|
@ -334,7 +334,7 @@ void Module::generate_cython_wrapper(const string& toolboxPath, const std::strin
|
|||
/* ************************************************************************* */
|
||||
void Module::emit_cython_pxd(FileWriter& pxdFile) const {
|
||||
// headers
|
||||
pxdFile.oss << "from eigency.core cimport *\n"
|
||||
pxdFile.oss << "from clonedEigency.core cimport *\n"
|
||||
"from libcpp.string cimport string\n"
|
||||
"from libcpp.vector cimport vector\n"
|
||||
"from libcpp.pair cimport pair\n"
|
||||
|
@ -416,7 +416,7 @@ void Module::emit_cython_pyx(FileWriter& pyxFile) const {
|
|||
for(const Qualified& q: Qualified::BasicTypedefs) {
|
||||
pyxFile.oss << "from " << pxdHeader << " cimport " << q.pxdClassName() << "\n";
|
||||
}
|
||||
pyxFile.oss << "from eigency.core cimport *\n"
|
||||
pyxFile.oss << "from clonedEigency.core cimport *\n"
|
||||
"from libcpp cimport bool\n\n"
|
||||
"from libcpp.pair cimport pair\n"
|
||||
"from libcpp.string cimport string\n"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
from eigency.core cimport *
|
||||
from clonedEigency.core cimport *
|
||||
from libcpp.string cimport string
|
||||
from libcpp.vector cimport vector
|
||||
from libcpp.pair cimport pair
|
||||
|
|
|
@ -4,7 +4,7 @@ cimport geometry
|
|||
from geometry cimport shared_ptr
|
||||
from geometry cimport dynamic_pointer_cast
|
||||
from geometry cimport make_shared
|
||||
from eigency.core cimport *
|
||||
from clonedEigency.core cimport *
|
||||
from libcpp cimport bool
|
||||
|
||||
from libcpp.pair cimport pair
|
||||
|
|
Loading…
Reference in New Issue