From 443bb0776bce839248b5854280452c5ca036340f Mon Sep 17 00:00:00 2001 From: Enrique Fernandez Date: Wed, 24 Feb 2016 16:55:22 -0500 Subject: [PATCH] Set FLAGS for CMAKE_BUILD_TYPE None MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set the FLAGS to the ones from RelWithDebInfo CMAKE_BUILD_TYPE See https://cmake.org/Wiki/CMake_Useful_Variables#Compilers_and_Tools Without this, the C and CXX FLAGS are this (wrong): -- C compilation flags : -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -- C++ compilation flags : -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 and the compilation fails with this and similar errors (because C++11 is needed): gtsam/navigation/ImuFactor.cpp:144:15: error: ‘nullptr’ was not declared in this scope return e != nullptr && base && pim; With this changes, the C and CXX FLAGS are this (good): -- C compilation flags : -std=c11 -g -O3 -Wall -DNDEBUG -- C++ compilation flags : -std=c++11 -g -O3 -Wall -DNDEBUG and everything compiles. --- cmake/GtsamBuildTypes.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/GtsamBuildTypes.cmake b/cmake/GtsamBuildTypes.cmake index a17d3b465..c8cd9df35 100644 --- a/cmake/GtsamBuildTypes.cmake +++ b/cmake/GtsamBuildTypes.cmake @@ -14,6 +14,8 @@ option(GTSAM_BUILD_TYPE_POSTFIXES "Enable/Disable appending the build typ # Add debugging flags but only on the first pass if(NOT FIRST_PASS_DONE) + # Set all CMAKE_BUILD_TYPE flags: + # (see https://cmake.org/Wiki/CMake_Useful_Variables#Compilers_and_Tools) if(MSVC) set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 /W3 /GR /EHsc /MP /DWINDOWS_LEAN_AND_MEAN /DEIGEN_INITIALIZE_MATRICES_BY_NAN" CACHE STRING "Flags used by the compiler during debug builds." FORCE) set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 /W3 /GR /EHsc /MP /DWINDOWS_LEAN_AND_MEAN /DEIGEN_INITIALIZE_MATRICES_BY_NAN" CACHE STRING "Flags used by the compiler during debug builds." FORCE) @@ -51,6 +53,9 @@ if(NOT FIRST_PASS_DONE) set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "${CMAKE__LINKER_FLAGS_RELEASE}" CACHE STRING "Linker flags during profiling builds." FORCE) mark_as_advanced(CMAKE_C_FLAGS_PROFILING CMAKE_CXX_FLAGS_PROFILING CMAKE_EXE_LINKER_FLAGS_PROFILING CMAKE_SHARED_LINKER_FLAGS_PROFILING) endif() + # Make CMAKE_BUILD_TYPE=None flags default to the CMAKE_BUILD_TYPE=RelWithDebInfo ones: + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_RELWITHDEBINFO}" CACHE STRING "Flags used by the compiler during none builds." FORCE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" CACHE STRING "Flags used by the compiler during none builds." FORCE) endif() # Clang uses a template depth that is less than standard and is too small