From 99c1dd812437f18a1f95f5b4bb180f76a130c8b0 Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Wed, 18 Apr 2018 08:12:34 +0200 Subject: [PATCH] Add compiler options for GCC and Clang when CMAKE_BUILD_TYPE is Debug When CMAKE_BUILD_TYPE is Debug and we are compiling with GCC, add the following options to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS: -O0 -fno-omit-frame-pointer -fno-inline Ditto for Clang, except that -fno-inline-functions is used instead of -fno-inline. cf. thread starting at https://sourceforge.net/p/flightgear/mailman/message/36295412/ --- CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d9160c0f..6b21730c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -397,7 +397,12 @@ if(CMAKE_COMPILER_IS_GNUCXX) message(WARNING "GCC 4.4 will be required soon, please upgrade") endif() - if(ENABLE_SIMD) + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -O0 -fno-omit-frame-pointer -fno-inline") + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -O0 -fno-omit-frame-pointer -fno-inline") + elseif (ENABLE_SIMD) if (X86 OR X86_64) set(CMAKE_C_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse") @@ -420,7 +425,12 @@ if (CLANG) # fix Boost compilation :( set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") - if(ENABLE_SIMD) + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -O0 -fno-omit-frame-pointer -fno-inline-functions") + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -O0 -fno-omit-frame-pointer -fno-inline-functions") + elseif (ENABLE_SIMD) if (X86 OR X86_64) set(CMAKE_C_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse")