Make matlab wrapping rely completely on the wrap project
parent
6f81bdea7b
commit
f03b12e420
|
@ -16,7 +16,6 @@ install(FILES
|
||||||
dllexport.h.in
|
dllexport.h.in
|
||||||
GtsamBuildTypes.cmake
|
GtsamBuildTypes.cmake
|
||||||
GtsamMakeConfigFile.cmake
|
GtsamMakeConfigFile.cmake
|
||||||
GtsamMatlabWrap.cmake
|
|
||||||
GtsamTesting.cmake
|
GtsamTesting.cmake
|
||||||
GtsamPrinting.cmake
|
GtsamPrinting.cmake
|
||||||
FindNumPy.cmake
|
FindNumPy.cmake
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
# Set the wrapping script variable
|
|
||||||
set(MATLAB_WRAP_SCRIPT "${GTSAM_SOURCE_DIR}/wrap/scripts/matlab_wrap.py")
|
|
||||||
|
|
||||||
# Set up cache options
|
|
||||||
option(GTSAM_MEX_BUILD_STATIC_MODULE "Build MATLAB wrapper statically (increases build time)" OFF)
|
|
||||||
set(GTSAM_BUILD_MEX_BINARY_FLAGS "" CACHE STRING "Extra flags for running Matlab MEX compilation")
|
|
||||||
set(GTSAM_TOOLBOX_INSTALL_PATH "" CACHE PATH "Matlab toolbox destination, blank defaults to CMAKE_INSTALL_PREFIX/gtsam_toolbox")
|
|
||||||
if(NOT GTSAM_TOOLBOX_INSTALL_PATH)
|
|
||||||
set(GTSAM_TOOLBOX_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/gtsam_toolbox")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(WRAP_MEX_BUILD_STATIC_MODULE ${GTSAM_MEX_BUILD_STATIC_MODULE})
|
|
||||||
set(WRAP_BUILD_MEX_BINARY_FLAGS ${GTSAM_BUILD_MEX_BINARY_FLAGS})
|
|
||||||
set(WRAP_TOOLBOX_INSTALL_PATH ${GTSAM_TOOLBOX_INSTALL_PATH})
|
|
||||||
set(WRAP_CUSTOM_MATLAB_PATH ${GTSAM_CUSTOM_MATLAB_PATH})
|
|
||||||
set(WRAP_BUILD_TYPE_POSTFIXES ${GTSAM_BUILD_TYPE_POSTFIXES})
|
|
||||||
|
|
||||||
# Fixup the Python paths
|
|
||||||
if(GTWRAP_DIR)
|
|
||||||
# packaged
|
|
||||||
set(GTWRAP_PACKAGE_DIR ${GTWRAP_DIR})
|
|
||||||
else()
|
|
||||||
set(GTWRAP_PACKAGE_DIR ${GTSAM_SOURCE_DIR}/wrap)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(MatlabWrap)
|
|
||||||
|
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
|
||||||
message(FATAL_ERROR "GTSAM_INSTALL_MATLAB_TOOLBOX and BUILD_SHARED_LIBS=OFF. The MATLAB wrapper cannot be compiled with a static GTSAM library because mex modules are themselves shared libraries. If you want a self-contained mex module, enable GTSAM_MEX_BUILD_STATIC_MODULE instead of BUILD_SHARED_LIBS=OFF.")
|
|
||||||
endif()
|
|
|
@ -67,32 +67,6 @@ Defines two useful functions for creating CTest unit tests. Also immediately cr
|
||||||
an empty string "" if nothing needs to be excluded.
|
an empty string "" if nothing needs to be excluded.
|
||||||
linkLibraries: The list of libraries to link to.
|
linkLibraries: The list of libraries to link to.
|
||||||
|
|
||||||
## GtsamMatlabWrap
|
|
||||||
|
|
||||||
include(GtsamMatlabWrap)
|
|
||||||
|
|
||||||
Defines functions for generating MATLAB wrappers. Also immediately creates several CMake options for configuring the wrapper.
|
|
||||||
|
|
||||||
* `wrap_and_install_library(interfaceHeader linkLibraries extraIncludeDirs extraMexFlags)` Generates wrap code and compiles the wrapper.
|
|
||||||
|
|
||||||
Usage example:
|
|
||||||
|
|
||||||
`wrap_and_install_library("lba.h" "" "" "")`
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
interfaceHeader: The relative or absolute path to the wrapper interface
|
|
||||||
definition file.
|
|
||||||
linkLibraries: Any *additional* libraries to link. Your project library
|
|
||||||
(e.g. `lba`), libraries it depends on, and any necessary
|
|
||||||
MATLAB libraries will be linked automatically. So normally,
|
|
||||||
leave this empty.
|
|
||||||
extraIncludeDirs: Any *additional* include paths required by dependent
|
|
||||||
libraries that have not already been added by
|
|
||||||
include_directories. Again, normally, leave this empty.
|
|
||||||
extraMexFlags: Any *additional* flags to pass to the compiler when building
|
|
||||||
the wrap code. Normally, leave this empty.
|
|
||||||
|
|
||||||
## GtsamMakeConfigFile
|
## GtsamMakeConfigFile
|
||||||
|
|
||||||
include(GtsamMakeConfigFile)
|
include(GtsamMakeConfigFile)
|
||||||
|
|
|
@ -204,18 +204,3 @@ else()
|
||||||
set_source_files_properties(${3rdparty_srcs} PROPERTIES COMPILE_FLAGS "-Wno-error")
|
set_source_files_properties(${3rdparty_srcs} PROPERTIES COMPILE_FLAGS "-Wno-error")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Create the matlab toolbox for the gtsam library
|
|
||||||
if (GTSAM_INSTALL_MATLAB_TOOLBOX)
|
|
||||||
# Set up codegen
|
|
||||||
include(GtsamMatlabWrap)
|
|
||||||
|
|
||||||
# Generate, build and install toolbox
|
|
||||||
set(mexFlags "${GTSAM_BUILD_MEX_BINARY_FLAGS}")
|
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
|
||||||
list(APPEND mexFlags -DGTSAM_IMPORT_STATIC)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Wrap
|
|
||||||
wrap_and_install_library(gtsam.i "${GTSAM_ADDITIONAL_LIBRARIES}" "" "${mexFlags}")
|
|
||||||
endif ()
|
|
||||||
|
|
|
@ -107,22 +107,6 @@ install(
|
||||||
list(APPEND GTSAM_EXPORTED_TARGETS gtsam_unstable)
|
list(APPEND GTSAM_EXPORTED_TARGETS gtsam_unstable)
|
||||||
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
|
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
|
||||||
|
|
||||||
# Wrap version for gtsam_unstable
|
|
||||||
if (GTSAM_UNSTABLE_INSTALL_MATLAB_TOOLBOX)
|
|
||||||
# Set up codegen
|
|
||||||
include(GtsamMatlabWrap)
|
|
||||||
|
|
||||||
# Generate, build and install toolbox
|
|
||||||
set(mexFlags "${GTSAM_BUILD_MEX_BINARY_FLAGS}")
|
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
|
||||||
list(APPEND mexFlags -DGTSAM_IMPORT_STATIC)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Wrap
|
|
||||||
wrap_and_install_library(gtsam_unstable.i "gtsam" "" "${mexFlags}")
|
|
||||||
endif(GTSAM_UNSTABLE_INSTALL_MATLAB_TOOLBOX)
|
|
||||||
|
|
||||||
|
|
||||||
# Build examples
|
# Build examples
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
|
|
||||||
|
|
|
@ -1,44 +1,124 @@
|
||||||
# Install matlab components
|
# Install matlab components
|
||||||
|
|
||||||
include(GtsamMatlabWrap)
|
# Create the matlab toolbox for the gtsam library
|
||||||
|
if(GTSAM_INSTALL_MATLAB_TOOLBOX)
|
||||||
|
|
||||||
# Record the root dir for gtsam - needed during external builds, e.g., ROS
|
# Set the wrapping script variable
|
||||||
set(GTSAM_SOURCE_ROOT_DIR ${GTSAM_SOURCE_DIR})
|
set(MATLAB_WRAP_SCRIPT "${GTSAM_SOURCE_DIR}/wrap/scripts/matlab_wrap.py")
|
||||||
message(STATUS "GTSAM_SOURCE_ROOT_DIR: [${GTSAM_SOURCE_ROOT_DIR}]")
|
|
||||||
|
|
||||||
# Tests
|
# Set up cache options
|
||||||
#message(STATUS "Installing Matlab Toolbox")
|
option(GTSAM_MEX_BUILD_STATIC_MODULE
|
||||||
install_matlab_scripts("${GTSAM_SOURCE_ROOT_DIR}/matlab/" "*.m;*.fig")
|
"Build MATLAB wrapper statically (increases build time)" OFF)
|
||||||
install_matlab_scripts("${GTSAM_SOURCE_ROOT_DIR}/matlab/" "README-gtsam-toolbox.txt")
|
set(GTSAM_BUILD_MEX_BINARY_FLAGS
|
||||||
|
""
|
||||||
|
CACHE STRING "Extra flags for running Matlab MEX compilation")
|
||||||
|
set(GTSAM_TOOLBOX_INSTALL_PATH
|
||||||
|
""
|
||||||
|
CACHE
|
||||||
|
PATH
|
||||||
|
"Matlab toolbox destination, blank defaults to CMAKE_INSTALL_PREFIX/gtsam_toolbox"
|
||||||
|
)
|
||||||
|
if(NOT GTSAM_TOOLBOX_INSTALL_PATH)
|
||||||
|
set(GTSAM_TOOLBOX_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/gtsam_toolbox")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Examples
|
set(WRAP_MEX_BUILD_STATIC_MODULE ${GTSAM_MEX_BUILD_STATIC_MODULE})
|
||||||
#message(STATUS "Installing Matlab Toolbox Examples")
|
set(WRAP_BUILD_MEX_BINARY_FLAGS ${GTSAM_BUILD_MEX_BINARY_FLAGS})
|
||||||
# Matlab files: *.m and *.fig
|
set(WRAP_TOOLBOX_INSTALL_PATH ${GTSAM_TOOLBOX_INSTALL_PATH})
|
||||||
#install_matlab_scripts("${GTSAM_SOURCE_ROOT_DIR}/matlab/gtsam_examples" "*.m;*.fig")
|
set(WRAP_CUSTOM_MATLAB_PATH ${GTSAM_CUSTOM_MATLAB_PATH})
|
||||||
|
set(WRAP_BUILD_TYPE_POSTFIXES ${GTSAM_BUILD_TYPE_POSTFIXES})
|
||||||
|
|
||||||
# Utilities
|
# Fixup the Python paths
|
||||||
#message(STATUS "Installing Matlab Toolbox Utilities")
|
if(GTWRAP_DIR)
|
||||||
#install_matlab_scripts("${GTSAM_SOURCE_ROOT_DIR}/matlab/+gtsam" "*.m")
|
# packaged
|
||||||
|
set(GTWRAP_PACKAGE_DIR ${GTWRAP_DIR})
|
||||||
|
else()
|
||||||
|
set(GTWRAP_PACKAGE_DIR ${GTSAM_SOURCE_DIR}/wrap)
|
||||||
|
endif()
|
||||||
|
|
||||||
#message(STATUS "Installing Matlab Toolbox Example Data")
|
include(MatlabWrap)
|
||||||
# Data files: *.graph, *.mat, and *.txt
|
|
||||||
file(GLOB matlab_examples_data_graph "${GTSAM_SOURCE_ROOT_DIR}/examples/Data/*.graph")
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
file(GLOB matlab_examples_data_mat "${GTSAM_SOURCE_ROOT_DIR}/examples/Data/*.mat")
|
message(
|
||||||
file(GLOB matlab_examples_data_txt "${GTSAM_SOURCE_ROOT_DIR}/examples/Data/*.txt")
|
FATAL_ERROR
|
||||||
set(matlab_examples_data ${matlab_examples_data_graph} ${matlab_examples_data_mat} ${matlab_examples_data_txt})
|
"GTSAM_INSTALL_MATLAB_TOOLBOX and BUILD_SHARED_LIBS=OFF."
|
||||||
if(GTSAM_BUILD_TYPE_POSTFIXES)
|
"The MATLAB wrapper cannot be compiled with a static GTSAM library because mex modules are themselves shared libraries."
|
||||||
foreach(build_type ${CMAKE_CONFIGURATION_TYPES})
|
"If you want a self-contained mex module, enable GTSAM_MEX_BUILD_STATIC_MODULE instead of BUILD_SHARED_LIBS=OFF."
|
||||||
string(TOUPPER "${build_type}" build_type_upper)
|
)
|
||||||
if(${build_type_upper} STREQUAL "RELEASE")
|
endif()
|
||||||
set(build_type_tag "") # Don't create release mode tag on installed directory
|
|
||||||
else()
|
# ############################################################################
|
||||||
set(build_type_tag "${build_type}")
|
# Generate, build and install toolbox
|
||||||
endif()
|
set(mexFlags "${GTSAM_BUILD_MEX_BINARY_FLAGS}")
|
||||||
# Split up filename to strip trailing '/' in GTSAM_TOOLBOX_INSTALL_PATH if there is one
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
get_filename_component(location "${GTSAM_TOOLBOX_INSTALL_PATH}" PATH)
|
list(APPEND mexFlags -DGTSAM_IMPORT_STATIC)
|
||||||
get_filename_component(name "${GTSAM_TOOLBOX_INSTALL_PATH}" NAME)
|
endif()
|
||||||
install(FILES ${matlab_examples_data} DESTINATION "${location}/${name}${build_type_tag}/gtsam_examples/Data" CONFIGURATIONS "${build_type}")
|
|
||||||
endforeach()
|
# Wrap
|
||||||
else()
|
wrap_and_install_library(${GTSAM_SOURCE_DIR}/gtsam/gtsam.i "${GTSAM_ADDITIONAL_LIBRARIES}" ""
|
||||||
install(FILES ${matlab_examples_data} DESTINATION ${GTSAM_TOOLBOX_INSTALL_PATH}/gtsam_examples/Data)
|
"${mexFlags}")
|
||||||
endif()
|
|
||||||
|
# Wrap version for gtsam_unstable
|
||||||
|
if(GTSAM_UNSTABLE_INSTALL_MATLAB_TOOLBOX)
|
||||||
|
# Generate, build and install toolbox
|
||||||
|
set(mexFlags "${GTSAM_BUILD_MEX_BINARY_FLAGS}")
|
||||||
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
|
list(APPEND mexFlags -DGTSAM_IMPORT_STATIC)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Wrap
|
||||||
|
wrap_and_install_library(${GTSAM_SOURCE_DIR}/gtsam_unstable/gtsam_unstable.i "gtsam" "" "${mexFlags}")
|
||||||
|
endif(GTSAM_UNSTABLE_INSTALL_MATLAB_TOOLBOX)
|
||||||
|
|
||||||
|
# Record the root dir for gtsam - needed during external builds, e.g., ROS
|
||||||
|
set(GTSAM_SOURCE_ROOT_DIR ${GTSAM_SOURCE_DIR})
|
||||||
|
message(STATUS "GTSAM_SOURCE_ROOT_DIR: [${GTSAM_SOURCE_ROOT_DIR}]")
|
||||||
|
|
||||||
|
# Tests message(STATUS "Installing Matlab Toolbox")
|
||||||
|
install_matlab_scripts("${GTSAM_SOURCE_ROOT_DIR}/matlab/" "*.m;*.fig")
|
||||||
|
install_matlab_scripts("${GTSAM_SOURCE_ROOT_DIR}/matlab/"
|
||||||
|
"README-gtsam-toolbox.txt")
|
||||||
|
|
||||||
|
# Examples message(STATUS "Installing Matlab Toolbox Examples") Matlab files:
|
||||||
|
# *.m and *.fig
|
||||||
|
# install_matlab_scripts("${GTSAM_SOURCE_ROOT_DIR}/matlab/gtsam_examples"
|
||||||
|
# "*.m;*.fig")
|
||||||
|
|
||||||
|
# Utilities message(STATUS "Installing Matlab Toolbox Utilities")
|
||||||
|
# install_matlab_scripts("${GTSAM_SOURCE_ROOT_DIR}/matlab/+gtsam" "*.m")
|
||||||
|
|
||||||
|
# message(STATUS "Installing Matlab Toolbox Example Data") Data files:
|
||||||
|
# *.graph, *.mat, and *.txt
|
||||||
|
file(GLOB matlab_examples_data_graph
|
||||||
|
"${GTSAM_SOURCE_ROOT_DIR}/examples/Data/*.graph")
|
||||||
|
file(GLOB matlab_examples_data_mat
|
||||||
|
"${GTSAM_SOURCE_ROOT_DIR}/examples/Data/*.mat")
|
||||||
|
file(GLOB matlab_examples_data_txt
|
||||||
|
"${GTSAM_SOURCE_ROOT_DIR}/examples/Data/*.txt")
|
||||||
|
set(matlab_examples_data
|
||||||
|
${matlab_examples_data_graph} ${matlab_examples_data_mat}
|
||||||
|
${matlab_examples_data_txt})
|
||||||
|
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_TOOLBOX_INSTALL_PATH if
|
||||||
|
# there is one
|
||||||
|
get_filename_component(location "${GTSAM_TOOLBOX_INSTALL_PATH}" PATH)
|
||||||
|
get_filename_component(name "${GTSAM_TOOLBOX_INSTALL_PATH}" NAME)
|
||||||
|
install(
|
||||||
|
FILES ${matlab_examples_data}
|
||||||
|
DESTINATION "${location}/${name}${build_type_tag}/gtsam_examples/Data"
|
||||||
|
CONFIGURATIONS "${build_type}")
|
||||||
|
endforeach()
|
||||||
|
else()
|
||||||
|
install(FILES ${matlab_examples_data}
|
||||||
|
DESTINATION ${GTSAM_TOOLBOX_INSTALL_PATH}/gtsam_examples/Data)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif(GTSAM_INSTALL_MATLAB_TOOLBOX)
|
||||||
|
|
Loading…
Reference in New Issue