Fixed path and compile problems with matlab wrapper on windows

release/4.3a0
Richard Roberts 2012-05-28 20:48:36 +00:00
parent 069be2b143
commit 592a251a05
8 changed files with 19 additions and 15 deletions

View File

@ -95,7 +95,7 @@ endif()
if(CYGWIN OR MSVC OR WIN32) if(CYGWIN OR MSVC OR WIN32)
set(Boost_USE_STATIC_LIBS 1) set(Boost_USE_STATIC_LIBS 1)
endif() 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 # General build settings
include_directories( include_directories(

View File

@ -46,7 +46,7 @@ void Argument::matlab_unwrap(FileWriter& file, const string& matlabName) const {
if (is_ptr) if (is_ptr)
// A pointer: emit an "unwrap_shared_ptr" call which returns a pointer // 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) else if (is_ref)
// A reference: emit an "unwrap_shared_ptr" call and de-reference the pointer // A reference: emit an "unwrap_shared_ptr" call and de-reference the pointer
file.oss << cppType << "& " << name << " = *unwrap_shared_ptr< "; file.oss << cppType << "& " << name << " = *unwrap_shared_ptr< ";

View File

@ -31,6 +31,9 @@ endif(GTSAM_BUILD_TESTS)
# [mexFlags] : extra flags for the mex command # [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") 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(toolbox_path ${CMAKE_BINARY_DIR}/wrap/gtsam)
set(moduleName gtsam) set(moduleName gtsam)
@ -43,8 +46,9 @@ if (NOT EXECUTABLE_OUTPUT_PATH)
endif() endif()
# Code generation command # Code generation command
get_property(WRAP_EXE TARGET wrap PROPERTY LOCATION)
add_custom_target(wrap_gtsam ALL COMMAND 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) DEPENDS wrap)
# Build command # Build command

View File

@ -73,7 +73,7 @@ void Method::matlab_wrapper(const string& classPath,
// get class pointer // get class pointer
// example: shared_ptr<Test> = unwrap_shared_ptr< Test >(in[0], "Test"); // 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; << " >(in[0],\"" << matlabClassName << "\");" << endl;
// unwrap arguments, see Argument.cpp // unwrap arguments, see Argument.cpp

View File

@ -294,7 +294,7 @@ void Module::matlab_code(const string& toolboxPath,
makeModuleMfile.oss << "echo on" << endl << endl; makeModuleMfile.oss << "echo on" << endl << endl;
makeModuleMfile.oss << "toolboxpath = mfilename('fullpath');" << 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 << "toolboxpath = toolboxpath(1:(delims(end)-1));" << endl;
makeModuleMfile.oss << "clear delims" << endl; makeModuleMfile.oss << "clear delims" << endl;
makeModuleMfile.oss << "addpath(toolboxpath);" << endl << endl; makeModuleMfile.oss << "addpath(toolboxpath);" << endl << endl;

View File

@ -53,7 +53,7 @@ void ReturnValue::wrap_result(FileWriter& file) const {
if (isPtr1) // if we already have a pointer if (isPtr1) // if we already have a pointer
file.oss << " out[0] = wrap_shared_ptr(result.first,\"" << matlabType1 << "\");\n"; file.oss << " out[0] = wrap_shared_ptr(result.first,\"" << matlabType1 << "\");\n";
else if (category1 == ReturnValue::CLASS) // if we are going to make one 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 else // if basis type
file.oss << " out[0] = wrap< " << return_type(true,arg1) << " >(result.first);\n"; 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 if (isPtr2) // if we already have a pointer
file.oss << " out[1] = wrap_shared_ptr(result.second,\"" << matlabType2 << "\");\n"; file.oss << " out[1] = wrap_shared_ptr(result.second,\"" << matlabType2 << "\");\n";
else if (category2 == ReturnValue::CLASS) // if we are going to make one 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 else
file.oss << " out[1] = wrap< " << return_type(true,arg2) << " >(result.second);\n"; file.oss << " out[1] = wrap< " << return_type(true,arg2) << " >(result.second);\n";
} }
else if (isPtr1) else if (isPtr1)
file.oss << " out[0] = wrap_shared_ptr(result,\"" << matlabType1 << "\");\n"; file.oss << " out[0] = wrap_shared_ptr(result,\"" << matlabType1 << "\");\n";
else if (category1 == ReturnValue::CLASS) 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") else if (matlabType1!="void")
file.oss << " out[0] = wrap< " << return_type(true,arg1) << " >(result);\n"; file.oss << " out[0] = wrap< " << return_type(true,arg1) << " >(result);\n";
} }

View File

@ -300,19 +300,19 @@ class ObjectHandle {
private: private:
ObjectHandle* signature; // use 'this' as a unique object signature ObjectHandle* signature; // use 'this' as a unique object signature
const std::type_info* type; // type checking information const std::type_info* type; // type checking information
shared_ptr<T> t; // object pointer boost::shared_ptr<T> t; // object pointer
public: public:
// Constructor for free-store allocated objects. // Constructor for free-store allocated objects.
// Creates shared pointer, will delete if is last one to hold pointer // Creates shared pointer, will delete if is last one to hold pointer
ObjectHandle(T* ptr) : ObjectHandle(T* ptr) :
type(&typeid(T)), t(shared_ptr<T> (ptr)) { type(&typeid(T)), t(boost::shared_ptr<T> (ptr)) {
signature = this; signature = this;
} }
// Constructor for shared pointers // Constructor for shared pointers
// Creates shared pointer, will delete if is last one to hold pointer // 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) { /*type(&typeid(T)),*/ t(ptr) {
signature = this; signature = this;
} }
@ -323,7 +323,7 @@ public:
} }
// Get the actual object contained by handle // Get the actual object contained by handle
shared_ptr<T> get_object() const { boost::shared_ptr<T> get_object() const {
return t; return t;
} }
@ -419,7 +419,7 @@ mxArray* create_object(const char *classname, mxArray* h) {
class to matlab. class to matlab.
*/ */
template <typename Class> 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); ObjectHandle<Class>* handle = new ObjectHandle<Class>(shared_ptr);
return create_object(classname,handle->to_mex_handle()); 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. to the object.
*/ */
template <typename Class> 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? //Why is this here?
#ifndef UNSAFE_WRAP #ifndef UNSAFE_WRAP
bool isClass = mxIsClass(obj, className.c_str()); bool isClass = mxIsClass(obj, className.c_str());

View File

@ -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 maybe_shared_ptr(bool add, const string& type) {
string str = add? "shared_ptr<" : ""; string str = add? "boost::shared_ptr<" : "";
str += type; str += type;
if (add) str += ">"; if (add) str += ">";
return str; return str;