Fixed path and compile problems with matlab wrapper on windows
parent
069be2b143
commit
592a251a05
|
@ -95,7 +95,7 @@ endif()
|
|||
if(CYGWIN OR MSVC OR WIN32)
|
||||
set(Boost_USE_STATIC_LIBS 1)
|
||||
endif()
|
||||
find_package(Boost 1.40 COMPONENTS serialization system chrono filesystem REQUIRED)
|
||||
find_package(Boost 1.40 COMPONENTS serialization system chrono filesystem thread REQUIRED)
|
||||
|
||||
# General build settings
|
||||
include_directories(
|
||||
|
|
|
@ -46,7 +46,7 @@ void Argument::matlab_unwrap(FileWriter& file, const string& matlabName) const {
|
|||
|
||||
if (is_ptr)
|
||||
// A pointer: emit an "unwrap_shared_ptr" call which returns a pointer
|
||||
file.oss << "shared_ptr<" << cppType << "> " << name << " = unwrap_shared_ptr< ";
|
||||
file.oss << "boost::shared_ptr<" << cppType << "> " << name << " = unwrap_shared_ptr< ";
|
||||
else if (is_ref)
|
||||
// A reference: emit an "unwrap_shared_ptr" call and de-reference the pointer
|
||||
file.oss << cppType << "& " << name << " = *unwrap_shared_ptr< ";
|
||||
|
|
|
@ -31,6 +31,9 @@ endif(GTSAM_BUILD_TESTS)
|
|||
# [mexFlags] : extra flags for the mex command
|
||||
|
||||
set(mexFlags "-I${Boost_INCLUDE_DIR} -I${CMAKE_INSTALL_PREFIX}/include -I${CMAKE_INSTALL_PREFIX}/include/gtsam -I${CMAKE_INSTALL_PREFIX}/include/gtsam/base -I${CMAKE_INSTALL_PREFIX}/include/gtsam/geometry -I${CMAKE_INSTALL_PREFIX}/include/gtsam/linear -I${CMAKE_INSTALL_PREFIX}/include/gtsam/nonlinear -I${CMAKE_INSTALL_PREFIX}/include/gtsam/slam -L${CMAKE_INSTALL_PREFIX}/lib -lgtsam")
|
||||
if(MSVC OR CYGWIN OR WINGW)
|
||||
set(mexFlags "${mexFlags} LINKFLAGS='$LINKFLAGS /LIBPATH:${Boost_LIBRARY_DIRS}'")
|
||||
endif()
|
||||
set(toolbox_path ${CMAKE_BINARY_DIR}/wrap/gtsam)
|
||||
set(moduleName gtsam)
|
||||
|
||||
|
@ -43,8 +46,9 @@ if (NOT EXECUTABLE_OUTPUT_PATH)
|
|||
endif()
|
||||
|
||||
# Code generation command
|
||||
get_property(WRAP_EXE TARGET wrap PROPERTY LOCATION)
|
||||
add_custom_target(wrap_gtsam ALL COMMAND
|
||||
${EXECUTABLE_OUTPUT_PATH}/wrap ${GTSAM_MEX_BIN_EXTENSION} ${CMAKE_CURRENT_SOURCE_DIR}/../ ${moduleName} ${toolbox_path} "${mexFlags}"
|
||||
${WRAP_EXE} ${GTSAM_MEX_BIN_EXTENSION} ${CMAKE_CURRENT_SOURCE_DIR}/../ ${moduleName} ${toolbox_path} "${mexFlags}"
|
||||
DEPENDS wrap)
|
||||
|
||||
# Build command
|
||||
|
|
|
@ -73,7 +73,7 @@ void Method::matlab_wrapper(const string& classPath,
|
|||
|
||||
// get class pointer
|
||||
// example: shared_ptr<Test> = unwrap_shared_ptr< Test >(in[0], "Test");
|
||||
file.oss << " shared_ptr<" << cppClassName << "> self = unwrap_shared_ptr< " << cppClassName
|
||||
file.oss << " boost::shared_ptr<" << cppClassName << "> self = unwrap_shared_ptr< " << cppClassName
|
||||
<< " >(in[0],\"" << matlabClassName << "\");" << endl;
|
||||
|
||||
// unwrap arguments, see Argument.cpp
|
||||
|
|
|
@ -294,7 +294,7 @@ void Module::matlab_code(const string& toolboxPath,
|
|||
|
||||
makeModuleMfile.oss << "echo on" << endl << endl;
|
||||
makeModuleMfile.oss << "toolboxpath = mfilename('fullpath');" << endl;
|
||||
makeModuleMfile.oss << "delims = find(toolboxpath == '/');" << endl;
|
||||
makeModuleMfile.oss << "delims = find(toolboxpath == '/' | toolboxpath == '\\');" << endl;
|
||||
makeModuleMfile.oss << "toolboxpath = toolboxpath(1:(delims(end)-1));" << endl;
|
||||
makeModuleMfile.oss << "clear delims" << endl;
|
||||
makeModuleMfile.oss << "addpath(toolboxpath);" << endl << endl;
|
||||
|
|
|
@ -53,7 +53,7 @@ void ReturnValue::wrap_result(FileWriter& file) const {
|
|||
if (isPtr1) // if we already have a pointer
|
||||
file.oss << " out[0] = wrap_shared_ptr(result.first,\"" << matlabType1 << "\");\n";
|
||||
else if (category1 == ReturnValue::CLASS) // if we are going to make one
|
||||
file.oss << " out[0] = wrap_shared_ptr(make_shared< " << cppType1 << " >(result.first),\"" << matlabType1 << "\");\n";
|
||||
file.oss << " out[0] = wrap_shared_ptr(boost::make_shared< " << cppType1 << " >(result.first),\"" << matlabType1 << "\");\n";
|
||||
else // if basis type
|
||||
file.oss << " out[0] = wrap< " << return_type(true,arg1) << " >(result.first);\n";
|
||||
|
||||
|
@ -61,14 +61,14 @@ void ReturnValue::wrap_result(FileWriter& file) const {
|
|||
if (isPtr2) // if we already have a pointer
|
||||
file.oss << " out[1] = wrap_shared_ptr(result.second,\"" << matlabType2 << "\");\n";
|
||||
else if (category2 == ReturnValue::CLASS) // if we are going to make one
|
||||
file.oss << " out[1] = wrap_shared_ptr(make_shared< " << cppType2 << " >(result.second),\"" << matlabType2 << "\");\n";
|
||||
file.oss << " out[1] = wrap_shared_ptr(boost::make_shared< " << cppType2 << " >(result.second),\"" << matlabType2 << "\");\n";
|
||||
else
|
||||
file.oss << " out[1] = wrap< " << return_type(true,arg2) << " >(result.second);\n";
|
||||
}
|
||||
else if (isPtr1)
|
||||
file.oss << " out[0] = wrap_shared_ptr(result,\"" << matlabType1 << "\");\n";
|
||||
else if (category1 == ReturnValue::CLASS)
|
||||
file.oss << " out[0] = wrap_shared_ptr(make_shared< " << cppType1 << " >(result),\"" << matlabType1 << "\");\n";
|
||||
file.oss << " out[0] = wrap_shared_ptr(boost::make_shared< " << cppType1 << " >(result),\"" << matlabType1 << "\");\n";
|
||||
else if (matlabType1!="void")
|
||||
file.oss << " out[0] = wrap< " << return_type(true,arg1) << " >(result);\n";
|
||||
}
|
||||
|
|
|
@ -300,19 +300,19 @@ class ObjectHandle {
|
|||
private:
|
||||
ObjectHandle* signature; // use 'this' as a unique object signature
|
||||
const std::type_info* type; // type checking information
|
||||
shared_ptr<T> t; // object pointer
|
||||
boost::shared_ptr<T> t; // object pointer
|
||||
|
||||
public:
|
||||
// Constructor for free-store allocated objects.
|
||||
// Creates shared pointer, will delete if is last one to hold pointer
|
||||
ObjectHandle(T* ptr) :
|
||||
type(&typeid(T)), t(shared_ptr<T> (ptr)) {
|
||||
type(&typeid(T)), t(boost::shared_ptr<T> (ptr)) {
|
||||
signature = this;
|
||||
}
|
||||
|
||||
// Constructor for shared pointers
|
||||
// Creates shared pointer, will delete if is last one to hold pointer
|
||||
ObjectHandle(shared_ptr<T> ptr) :
|
||||
ObjectHandle(boost::shared_ptr<T> ptr) :
|
||||
/*type(&typeid(T)),*/ t(ptr) {
|
||||
signature = this;
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ public:
|
|||
}
|
||||
|
||||
// Get the actual object contained by handle
|
||||
shared_ptr<T> get_object() const {
|
||||
boost::shared_ptr<T> get_object() const {
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ mxArray* create_object(const char *classname, mxArray* h) {
|
|||
class to matlab.
|
||||
*/
|
||||
template <typename Class>
|
||||
mxArray* wrap_shared_ptr(shared_ptr< Class > shared_ptr, const char *classname) {
|
||||
mxArray* wrap_shared_ptr(boost::shared_ptr< Class > shared_ptr, const char *classname) {
|
||||
ObjectHandle<Class>* handle = new ObjectHandle<Class>(shared_ptr);
|
||||
return create_object(classname,handle->to_mex_handle());
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ mxArray* wrap_shared_ptr(shared_ptr< Class > shared_ptr, const char *classname)
|
|||
to the object.
|
||||
*/
|
||||
template <typename Class>
|
||||
shared_ptr<Class> unwrap_shared_ptr(const mxArray* obj, const string& className) {
|
||||
boost::shared_ptr<Class> unwrap_shared_ptr(const mxArray* obj, const string& className) {
|
||||
//Why is this here?
|
||||
#ifndef UNSAFE_WRAP
|
||||
bool isClass = mxIsClass(obj, className.c_str());
|
||||
|
|
|
@ -104,7 +104,7 @@ bool files_equal(const string& expected, const string& actual, bool skipheader)
|
|||
|
||||
/* ************************************************************************* */
|
||||
string maybe_shared_ptr(bool add, const string& type) {
|
||||
string str = add? "shared_ptr<" : "";
|
||||
string str = add? "boost::shared_ptr<" : "";
|
||||
str += type;
|
||||
if (add) str += ">";
|
||||
return str;
|
||||
|
|
Loading…
Reference in New Issue