Set FLAGS for CMAKE_BUILD_TYPE None

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.
release/4.3a0
Enrique Fernandez 2016-02-24 16:55:22 -05:00
parent 3226ec1d6a
commit 443bb0776b
1 changed files with 5 additions and 0 deletions

View File

@ -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