From 4e9ba66555475a4f7148b2ba1b7d6c9618ea882d Mon Sep 17 00:00:00 2001 From: matlabbe Date: Tue, 1 Dec 2015 11:51:59 -0500 Subject: [PATCH] Ubuntu 12.04 an g2o, fixed -std=c++11 error --- CMakeLists.txt | 16 ++++++++++++++++ cmake_modules/FindG2O.cmake | 4 +++- corelib/src/CMakeLists.txt | 2 -- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57c87316..664f5395 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,6 +202,22 @@ IF(WITH_GTSAM) FIND_PACKAGE(GTSAM QUIET) ENDIF(WITH_GTSAM) +IF(G2O_FOUND OR GTSAM_FOUND) + #Newest versions require std11 + IF(NOT MSVC) + include(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) + CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) + IF(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + ELSEIF(COMPILER_SUPPORTS_CXX0X) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + ELSE() + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler if you want to use g2o or gtsam (set \"-DWITH_G2O=OFF -DWITH_GTSAM=OFF\" to build without g2o and gtsam).") + ENDIF() + ENDIF() +ENDIF(G2O_FOUND OR GTSAM_FOUND) + IF(WITH_FLYCAPTURE2) FIND_PACKAGE(FlyCapture2 QUIET) IF(FlyCapture2_FOUND) diff --git a/cmake_modules/FindG2O.cmake b/cmake_modules/FindG2O.cmake index 892c0933..a16cd204 100644 --- a/cmake_modules/FindG2O.cmake +++ b/cmake_modules/FindG2O.cmake @@ -79,4 +79,6 @@ IF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_SOLVERS_FO ${CSPARSE_LIBRARY} cholmod) SET(G2O_FOUND "YES") -ENDIF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR AND G2O_SOLVERS_FOUND AND CSPARSE_FOUND) +ELSEIF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR) + MESSAGE(STATUS "g2o core libraries found but some solvers are missing. Make sure to install \"libsuitesparse-dev\" before building/installing g2o.") +ENDIF(G2O_STUFF_LIBRARY AND G2O_CORE_LIBRARY AND G2O_INCLUDE_DIR) diff --git a/corelib/src/CMakeLists.txt b/corelib/src/CMakeLists.txt index 9afae0de..1b3d0ed2 100644 --- a/corelib/src/CMakeLists.txt +++ b/corelib/src/CMakeLists.txt @@ -153,8 +153,6 @@ IF(G2O_FOUND) ${LIBRARIES} ${G2O_LIBRARIES} ) - #Newest versions require std11 - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") SET(SRC_FILES ${SRC_FILES}