From 3b4fd765ecef46b938050d2bbf1216d1bbd592ba Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Mon, 23 Dec 2013 14:41:49 -0500 Subject: [PATCH] Merged wrap improvements back from develop branch --- wrap/CMakeLists.txt | 14 +++++++++----- wrap/Module.cpp | 11 ++++++++++- wrap/matlab.h | 1 + wrap/tests/testWrap.cpp | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/wrap/CMakeLists.txt b/wrap/CMakeLists.txt index 399600b7e..28f8bea48 100644 --- a/wrap/CMakeLists.txt +++ b/wrap/CMakeLists.txt @@ -2,6 +2,12 @@ set(WRAP_BOOST_LIBRARIES ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_REGEX_LIBRARY}) +# Allow for disabling serialization to handle errors related to Clang's linker +option(GTSAM_WRAP_SERIALIZATION "If enabled, allows for wrapped objects to be saved via boost.serialization" ON) +if (NOT GTSAM_WRAP_SERIALIZATION) + add_definitions(-DWRAP_DISABLE_SERIALIZE) +endif() + # Build the executable itself file(GLOB wrap_srcs "*.cpp") file(GLOB wrap_headers "*.h") @@ -17,11 +23,9 @@ file(RELATIVE_PATH relative_path "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE set_target_properties(wrap_lib wrap PROPERTIES FOLDER "${relative_path}") # Install wrap binary and export target -if (GTSAM_INSTALL_WRAP) - install(TARGETS wrap EXPORT GTSAM-exports DESTINATION bin) - list(APPEND GTSAM_EXPORTED_TARGETS wrap) - set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) -endif(GTSAM_INSTALL_WRAP) +install(TARGETS wrap EXPORT GTSAM-exports DESTINATION bin) +list(APPEND GTSAM_EXPORTED_TARGETS wrap) +set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) # Install matlab header install(FILES matlab.h DESTINATION include/wrap) diff --git a/wrap/Module.cpp b/wrap/Module.cpp index a31f57e79..3cfdf2903 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -20,7 +20,7 @@ #include "Module.h" #include "FileWriter.h" #include "TypeAttributesTable.h" -#include "utilities.h" +#include "utilities.h" //#define BOOST_SPIRIT_DEBUG #include "spirit_actors.h" @@ -382,14 +382,22 @@ void Module::parseMarkup(const std::string& data) { BOOST_FOREACH(Class& cls, classes) { Class::Methods::iterator serializable_it = cls.methods.find("serializable"); if (serializable_it != cls.methods.end()) { +#ifndef WRAP_DISABLE_SERIALIZE cls.isSerializable = true; +#else + cout << "Ignoring serializable() flag in class " << cls.name << endl; +#endif cls.methods.erase(serializable_it); } Class::Methods::iterator serialize_it = cls.methods.find("serialize"); if (serialize_it != cls.methods.end()) { +#ifndef WRAP_DISABLE_SERIALIZE cls.isSerializable = true; cls.hasSerialization= true; +#else + cout << "Ignoring serialize() flag in class " << cls.name << endl; +#endif cls.methods.erase(serialize_it); } } @@ -449,6 +457,7 @@ void Module::generateIncludes(FileWriter& file) const { file.oss << "#include <" << *it << ">" << endl; file.oss << "\n"; } + /* ************************************************************************* */ void Module::matlab_code(const string& toolboxPath, const string& headerPath) const { diff --git a/wrap/matlab.h b/wrap/matlab.h index 30e759c83..c84d6fdec 100644 --- a/wrap/matlab.h +++ b/wrap/matlab.h @@ -225,6 +225,7 @@ mxArray* wrap(const gtsam::Matrix& A) { template T unwrap(const mxArray* array) { error("wrap internal error: attempted unwrap of invalid type"); + return T(); } // specialization to string diff --git a/wrap/tests/testWrap.cpp b/wrap/tests/testWrap.cpp index 461f00405..8bf2c1412 100644 --- a/wrap/tests/testWrap.cpp +++ b/wrap/tests/testWrap.cpp @@ -58,7 +58,7 @@ TEST( wrap, ArgumentList ) { } /* ************************************************************************* */ -TEST_UNSAFE( wrap, check_exception ) { +TEST( wrap, check_exception ) { THROWS_EXCEPTION(Module("/notarealpath", "geometry",enable_verbose)); CHECK_EXCEPTION(Module("/alsonotarealpath", "geometry",enable_verbose), CantOpenFile);