From 4e35ffdfab1c86487cdad33d8eebf29ee3ceee04 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 20 Jan 2017 13:02:58 -0800 Subject: [PATCH] cmake: check -momit-leaf-frame-pointer before using it Summary: because not all archs support this option. see https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html. also do not pass "-fno-omit-frame-pointer" and "-momit-leaf-frame-pointer" to compiler if ${CMAKE_BUILD_TYPE} is "Debug". this matches the behaviour of DEBUG_LEVEL=2 in Makefile. Signed-off-by: Kefu Chai Closes https://github.com/facebook/rocksdb/pull/1762 Differential Revision: D4444036 Pulled By: yiwu-arbug fbshipit-source-id: 8596fbe --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 460d13a38..4e0d9b355 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,14 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wextra -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -momit-leaf-frame-pointer") + if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer") + include(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-momit-leaf-frame-pointer" HAVE_OMIT_LEAF_FRAME_POINTER) + if(HAVE_OMIT_LEAF_FRAME_POINTER) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -momit-leaf-frame-pointer") + endif() + endif() endif() option(FAIL_ON_WARNINGS "Treat compile warnings as errors" ON)