diff --git a/CMakeLists.txt b/CMakeLists.txt index 45461eb78..fccbced99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,8 @@ include(DispatchSanitization) include(DispatchCompilerWarnings) include(DTrace) +include(EnableFramePointers) + # NOTE(abdulras) this is the CMake supported way to control whether we generate # shared or static libraries. This impacts the behaviour of `add_library` in # what type of library it generates. diff --git a/cmake/modules/EnableFramePointers.cmake b/cmake/modules/EnableFramePointers.cmake new file mode 100644 index 000000000..8573d8dc4 --- /dev/null +++ b/cmake/modules/EnableFramePointers.cmake @@ -0,0 +1,13 @@ +# +# Including this file enables frame pointers, if we know how. +# + +include(CheckCompilerFlag) + +# Check if the compiler supports -fno-omit-frame-pointer +check_compiler_flag(C -fno-omit-frame-pointer SUPPORTS_NO_OMIT_FP) + +# If it does, use it +if (SUPPORTS_NO_OMIT_FP) + add_compile_options($<$:-fno-omit-frame-pointer>) +endif()