diff --git a/CMakeLists.txt b/CMakeLists.txt index 12f1e614f..7be750b02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( diff --git a/wrap/Argument.cpp b/wrap/Argument.cpp index ff42b33b1..b03431d72 100644 --- a/wrap/Argument.cpp +++ b/wrap/Argument.cpp @@ -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< "; diff --git a/wrap/CMakeLists.txt b/wrap/CMakeLists.txt index 36415df35..a4286df98 100644 --- a/wrap/CMakeLists.txt +++ b/wrap/CMakeLists.txt @@ -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 diff --git a/wrap/Method.cpp b/wrap/Method.cpp index 3d53956f1..7261c88a0 100644 --- a/wrap/Method.cpp +++ b/wrap/Method.cpp @@ -73,7 +73,7 @@ void Method::matlab_wrapper(const string& classPath, // get class pointer // example: shared_ptr = 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 diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 98525e65d..af2238038 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.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; diff --git a/wrap/ReturnValue.cpp b/wrap/ReturnValue.cpp index 2095abc5e..ace1159ec 100644 --- a/wrap/ReturnValue.cpp +++ b/wrap/ReturnValue.cpp @@ -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"; } diff --git a/wrap/matlab.h b/wrap/matlab.h index b6d200e43..a69d8aba4 100644 --- a/wrap/matlab.h +++ b/wrap/matlab.h @@ -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; // object pointer + boost::shared_ptr 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 (ptr)) { + type(&typeid(T)), t(boost::shared_ptr (ptr)) { signature = this; } // Constructor for shared pointers // Creates shared pointer, will delete if is last one to hold pointer - ObjectHandle(shared_ptr ptr) : + ObjectHandle(boost::shared_ptr ptr) : /*type(&typeid(T)),*/ t(ptr) { signature = this; } @@ -323,7 +323,7 @@ public: } // Get the actual object contained by handle - shared_ptr get_object() const { + boost::shared_ptr get_object() const { return t; } @@ -419,7 +419,7 @@ mxArray* create_object(const char *classname, mxArray* h) { class to matlab. */ template -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* handle = new ObjectHandle(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 -shared_ptr unwrap_shared_ptr(const mxArray* obj, const string& className) { +boost::shared_ptr unwrap_shared_ptr(const mxArray* obj, const string& className) { //Why is this here? #ifndef UNSAFE_WRAP bool isClass = mxIsClass(obj, className.c_str()); diff --git a/wrap/utilities.cpp b/wrap/utilities.cpp index 7b82d9b9d..bfd1e77df 100644 --- a/wrap/utilities.cpp +++ b/wrap/utilities.cpp @@ -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;