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.
This commit is contained in:
Rafael Kitover 2017-02-03 12:39:10 -08:00
parent 6ecab805e0
commit fcc34394c1
1 changed files with 7 additions and 2 deletions

View File

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