From fcc34394c1394016cfed9fd21955970b396de59a Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Fri, 3 Feb 2017 12:39:10 -0800 Subject: [PATCH] fix build failure on OS X Lion with XCode 4.2 XCode 4.2 generates a broken binary if -fomit-frame-pointer and/or -flto is used for compile and link flags. Check for Clang version less than 4.3 on APPLE and remove these flags in the compile options setting cmake code. --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d51eaf7..a583dd15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,7 @@ ENDIF() # Compiler flags -IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) SET(LTO_FLAG "") IF(ENABLE_LTO) IF(CMAKE_COMPILER_IS_GNUCXX) @@ -286,7 +286,12 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") ENDIF(ENABLE_LTO) # common optimization flags - SET(MY_C_OPT_FLAGS -O2 -mtune=generic -fomit-frame-pointer ${LTO_FLAG}) + IF(NOT (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3)) + SET(MY_C_OPT_FLAGS -O2 -mtune=generic -fomit-frame-pointer ${LTO_FLAG}) + ELSE() + # LTO and -fomit-frame-pointer generate broken binaries on Lion with XCode 4.2 tools + SET(MY_C_OPT_FLAGS -O2 -mtune=generic) + ENDIF() # common debug flags IF(CMAKE_COMPILER_IS_GNUCXX)