From 178b7f29da0bd527b4a89b243ab1b1a9ee0e7f81 Mon Sep 17 00:00:00 2001 From: cbeall3 Date: Mon, 17 Mar 2014 21:56:50 -0400 Subject: [PATCH 1/5] clang warnings --- gtsam/linear/GaussianFactorGraph.h | 3 +++ gtsam_unstable/partition/GenericGraph.cpp | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gtsam/linear/GaussianFactorGraph.h b/gtsam/linear/GaussianFactorGraph.h index aea90da1a..50442ac6b 100644 --- a/gtsam/linear/GaussianFactorGraph.h +++ b/gtsam/linear/GaussianFactorGraph.h @@ -88,6 +88,9 @@ namespace gtsam { template GaussianFactorGraph(const FactorGraph& graph) : Base(graph) {} + /** Virtual destructor */ + virtual ~GaussianFactorGraph() {} + /// @name Testable /// @{ diff --git a/gtsam_unstable/partition/GenericGraph.cpp b/gtsam_unstable/partition/GenericGraph.cpp index aca916a04..a3db6a9c1 100644 --- a/gtsam_unstable/partition/GenericGraph.cpp +++ b/gtsam_unstable/partition/GenericGraph.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -468,9 +469,9 @@ namespace gtsam { namespace partition { } if (minFoundConstraintsPerCamera < minNrConstraintsPerCamera) - throw runtime_error("checkSingularity:minConstraintsPerCamera < " + minFoundConstraintsPerCamera); + throw runtime_error("checkSingularity:minConstraintsPerCamera < " + boost::lexical_cast(minFoundConstraintsPerCamera)); if (minFoundConstraintsPerLandmark < minNrConstraintsPerLandmark) - throw runtime_error("checkSingularity:minConstraintsPerLandmark < " + minFoundConstraintsPerLandmark); + throw runtime_error("checkSingularity:minConstraintsPerLandmark < " + boost::lexical_cast(minFoundConstraintsPerLandmark)); } }} // namespace From cb3cec378923de4fb6e124853bd89917cdd17c61 Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Thu, 27 Mar 2014 16:15:29 -0400 Subject: [PATCH 2/5] Replaced static variable counter inside ISAM2 update() with a member variable to avoid a bug where if multiple instances of ISAM2 are running in the same process, the counter gets incremented in each of them, resulting in very difficult to debug failures. --- gtsam/nonlinear/ISAM2.cpp | 10 +++++----- gtsam/nonlinear/ISAM2.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gtsam/nonlinear/ISAM2.cpp b/gtsam/nonlinear/ISAM2.cpp index 2c2b4b719..6d6785b14 100644 --- a/gtsam/nonlinear/ISAM2.cpp +++ b/gtsam/nonlinear/ISAM2.cpp @@ -151,13 +151,13 @@ void ISAM2Clique::print(const std::string& s, const KeyFormatter& formatter) con } /* ************************************************************************* */ -ISAM2::ISAM2(const ISAM2Params& params): params_(params) { +ISAM2::ISAM2(const ISAM2Params& params): params_(params), update_count_(0) { if(params_.optimizationParams.type() == typeid(ISAM2DoglegParams)) doglegDelta_ = boost::get(params_.optimizationParams).initialDelta; } /* ************************************************************************* */ -ISAM2::ISAM2() { +ISAM2::ISAM2() : update_count_(0) { if(params_.optimizationParams.type() == typeid(ISAM2DoglegParams)) doglegDelta_ = boost::get(params_.optimizationParams).initialDelta; } @@ -521,8 +521,7 @@ ISAM2Result ISAM2::update( gttic(ISAM2_update); - static int count = 0; - count++; + this->update_count_++; lastAffectedVariableCount = 0; lastAffectedFactorCount = 0; @@ -533,7 +532,8 @@ ISAM2Result ISAM2::update( ISAM2Result result; if(params_.enableDetailedResults) result.detail = ISAM2Result::DetailedResults(); - const bool relinearizeThisStep = force_relinearize || (params_.enableRelinearization && count % params_.relinearizeSkip == 0); + const bool relinearizeThisStep = force_relinearize + || (params_.enableRelinearization && update_count_ % params_.relinearizeSkip == 0); if(verbose) { cout << "ISAM2::update\n"; diff --git a/gtsam/nonlinear/ISAM2.h b/gtsam/nonlinear/ISAM2.h index 9eac64b4d..a98ef851f 100644 --- a/gtsam/nonlinear/ISAM2.h +++ b/gtsam/nonlinear/ISAM2.h @@ -468,6 +468,8 @@ protected: * variables and thus cannot have their linearization points changed. */ FastSet fixedVariables_; + int update_count_; ///< Counter incremented every update(), used to determine periodic relinearization + public: typedef ISAM2 This; ///< This class From 268bc189ce850e581f0686116a5d33aecdb09965 Mon Sep 17 00:00:00 2001 From: Andrew Melim Date: Thu, 3 Apr 2014 16:31:55 -0400 Subject: [PATCH 3/5] Detect clang to prevent issues with llvm --- gtsam/3rdparty/metis-5.1.0/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt b/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt index ceeb5d2aa..5b93baf39 100644 --- a/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt +++ b/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt @@ -2,9 +2,12 @@ cmake_minimum_required(VERSION 2.8) project(METIS) # Add flags for currect directory and below -add_definitions(-Wno-unused-variable) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_definitions(-Wno-unused-variable) + add_definitions(-Wno-sometimes-uninitialized) +endif() + add_definitions(-Wno-unknown-pragmas) -add_definitions(-Wno-sometimes-uninitialized) set(GKLIB_PATH ${PROJECT_SOURCE_DIR}/GKlib CACHE PATH "path to GKlib") set(SHARED FALSE CACHE BOOL "build a shared library") From 49c11e8fa7dc97d1d4d7f885031348fdaa6f0a82 Mon Sep 17 00:00:00 2001 From: Andrew Melim Date: Thu, 3 Apr 2014 16:35:10 -0400 Subject: [PATCH 4/5] Remove warning flag --- gtsam/3rdparty/metis-5.1.0/GKlib/GKlibSystem.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtsam/3rdparty/metis-5.1.0/GKlib/GKlibSystem.cmake b/gtsam/3rdparty/metis-5.1.0/GKlib/GKlibSystem.cmake index 3fcc29108..7ea5bab94 100644 --- a/gtsam/3rdparty/metis-5.1.0/GKlib/GKlibSystem.cmake +++ b/gtsam/3rdparty/metis-5.1.0/GKlib/GKlibSystem.cmake @@ -33,7 +33,7 @@ if(CMAKE_COMPILER_IS_GNUCC) set(GKlib_COPTIONS "${GKlib_COPTIONS} -fPIC") endif(NOT MINGW) # GCC warnings. - set(GKlib_COPTIONS "${GKlib_COPTIONS} -Wall -pedantic -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unknown-pragmas") + set(GKlib_COPTIONS "${GKlib_COPTIONS} -Wall -pedantic -Wno-unused-variable -Wno-unknown-pragmas") elseif(${CMAKE_C_COMPILER_ID} MATCHES "Sun") # Sun insists on -xc99. set(GKlib_COPTIONS "${GKlib_COPTIONS} -xc99") From e98b90bd2a0530816e91a4445d84ad4f66f89590 Mon Sep 17 00:00:00 2001 From: Andrew Melim Date: Fri, 4 Apr 2014 15:49:04 -0400 Subject: [PATCH 5/5] Make building of metis/partition optional via cmake flag --- gtsam/3rdparty/CMakeLists.txt | 5 +++- gtsam/3rdparty/metis-5.1.0/CMakeLists.txt | 1 + gtsam_unstable/CMakeLists.txt | 32 ++++++++++++++--------- gtsam_unstable/partition/CMakeLists.txt | 2 +- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/gtsam/3rdparty/CMakeLists.txt b/gtsam/3rdparty/CMakeLists.txt index f77454b9b..5822a51f5 100644 --- a/gtsam/3rdparty/CMakeLists.txt +++ b/gtsam/3rdparty/CMakeLists.txt @@ -25,8 +25,11 @@ if(NOT GTSAM_USE_SYSTEM_EIGEN) FILES_MATCHING PATTERN "*.h") endif() +option(GTSAM_BUILD_METIS "Build metis library" ON) option(GTSAM_BUILD_METIS_EXECUTABLES "Build metis library executables" OFF) -add_subdirectory(metis-5.1.0) +if(GTSAM_BUILD_METIS) + add_subdirectory(metis-5.1.0) +endif(GTSAM_BUILD_METIS) ############ NOTE: When updating GeographicLib be sure to disable building their examples ############ and unit tests by commenting out their lines: # add_subdirectory (examples) diff --git a/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt b/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt index 5b93baf39..827e50b34 100644 --- a/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt +++ b/gtsam/3rdparty/metis-5.1.0/CMakeLists.txt @@ -8,6 +8,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") endif() add_definitions(-Wno-unknown-pragmas) +add_definitions(-Wunused-but-set-variable) set(GKLIB_PATH ${PROJECT_SOURCE_DIR}/GKlib CACHE PATH "path to GKlib") set(SHARED FALSE CACHE BOOL "build a shared library") diff --git a/gtsam_unstable/CMakeLists.txt b/gtsam_unstable/CMakeLists.txt index 2e1097130..a33a4548c 100644 --- a/gtsam_unstable/CMakeLists.txt +++ b/gtsam_unstable/CMakeLists.txt @@ -1,15 +1,18 @@ # Build full gtsam_unstable library as a single library -# and also build tests +# and also build tests set (gtsam_unstable_subdirs - base + base geometry discrete dynamics nonlinear - partition slam ) +if(GTSAM_BUILD_METIS) # Only build partition if metis is built + set (gtsam_unstable_subdirs ${gtsam_unstable_subdirs} partition) +endif(GTSAM_BUILD_METIS) + set(GTSAM_UNSTABLE_BOOST_LIBRARIES ${GTSAM_BOOST_LIBRARIES}) add_custom_target(check.unstable COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure) @@ -22,7 +25,7 @@ set (excluded_sources # "") ) set (excluded_headers # "") - "${CMAKE_CURRENT_SOURCE_DIR}/slam/serialization.h" + "${CMAKE_CURRENT_SOURCE_DIR}/slam/serialization.h" ) # assemble core libaries @@ -36,32 +39,35 @@ foreach(subdir ${gtsam_unstable_subdirs}) gtsam_assign_source_folders("${${subdir}_srcs}") # Create MSVC structure # Build local library and tests - message(STATUS "Building ${subdir}_unstable") + message(STATUS "Building ${subdir}_unstable") add_subdirectory(${subdir}) endforeach(subdir) - + # assemble gtsam_unstable components set(gtsam_unstable_srcs - ${base_srcs} + ${base_srcs} ${geometry_srcs} ${discrete_srcs} - ${dynamics_srcs} + ${dynamics_srcs} ${nonlinear_srcs} - ${partition_srcs} ${slam_srcs} ) +if(GTSAM_BUILD_METIS) # Only build partition if metis is built + set (gtsam_unstable_srcs ${gtsam_unstable_srcs} ${partition_srcs}) +endif(GTSAM_BUILD_METIS) + # Versions - same as core gtsam library set(gtsam_unstable_version ${GTSAM_VERSION_MAJOR}.${GTSAM_VERSION_MINOR}.${GTSAM_VERSION_PATCH}) set(gtsam_unstable_soversion ${GTSAM_VERSION_MAJOR}) message(STATUS "GTSAM_UNSTABLE Version: ${gtsam_unstable_version}") message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") - + # build shared and static versions of the library if (GTSAM_BUILD_STATIC_LIBRARY) message(STATUS "Building GTSAM_UNSTABLE - static") add_library(gtsam_unstable STATIC ${gtsam_unstable_srcs}) - set_target_properties(gtsam_unstable PROPERTIES + set_target_properties(gtsam_unstable PROPERTIES OUTPUT_NAME gtsam_unstable CLEAN_DIRECT_OUTPUT 1 VERSION ${gtsam_unstable_version} @@ -78,7 +84,7 @@ if (GTSAM_BUILD_STATIC_LIBRARY) else() message(STATUS "Building GTSAM_UNSTABLE - shared") add_library(gtsam_unstable SHARED ${gtsam_unstable_srcs}) - set_target_properties(gtsam_unstable PROPERTIES + set_target_properties(gtsam_unstable PROPERTIES OUTPUT_NAME gtsam_unstable CLEAN_DIRECT_OUTPUT 1 VERSION ${gtsam_unstable_version} @@ -99,7 +105,7 @@ endif() if (GTSAM_INSTALL_MATLAB_TOOLBOX) # Set up codegen include(GtsamMatlabWrap) - + # Generate, build and install toolbox set(mexFlags "${GTSAM_BUILD_MEX_BINARY_FLAGS}") if(GTSAM_BUILD_STATIC_LIBRARY) diff --git a/gtsam_unstable/partition/CMakeLists.txt b/gtsam_unstable/partition/CMakeLists.txt index 9020346bf..d8d254513 100644 --- a/gtsam_unstable/partition/CMakeLists.txt +++ b/gtsam_unstable/partition/CMakeLists.txt @@ -4,4 +4,4 @@ install(FILES ${partition_headers} DESTINATION include/gtsam_unstable/parition) set(ignore_test "tests/testNestedDissection.cpp") # Add all tests -gtsamAddTestsGlob(partition_unstable "tests/*.cpp" "${ignore_test}" "gtsam_unstable;metis") \ No newline at end of file +gtsamAddTestsGlob(partition_unstable "tests/*.cpp" "${ignore_test}" "gtsam_unstable;metis")