add LTO option, disable on GCC+AMD64+Win32
Add ENABLE_LTO cmake option that defaults to ON except on GCC building for AMD64 on Win32. Also set the cmake variables AMD64 or X86_32 when one of these architectures is detected.
This commit is contained in:
parent
7f6374356d
commit
37518fc88b
|
@ -29,11 +29,15 @@ SET(ASM_SCALERS_DEFAULT OFF)
|
|||
SET(MMX_DEFAULT OFF)
|
||||
|
||||
# turn asm on by default on 32bit x86
|
||||
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86|[aA][mM][dD]64|[xX]64"
|
||||
AND CMAKE_C_SIZEOF_DATA_PTR EQUAL 4)
|
||||
SET(ASM_CORE_DEFAULT ON)
|
||||
SET(ASM_SCALERS_DEFAULT ON)
|
||||
SET(MMX_DEFAULT ON)
|
||||
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86|[aA][mM][dD]64|[xX]64")
|
||||
IF(CMAKE_C_SIZEOF_DATA_PTR EQUAL 4) # 32 bit
|
||||
SET(ASM_CORE_DEFAULT ON)
|
||||
SET(ASM_SCALERS_DEFAULT ON)
|
||||
SET(MMX_DEFAULT ON)
|
||||
SET(X86_32 ON)
|
||||
ELSE()
|
||||
SET(AMD64 ON)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
option( ENABLE_ASM_CORE "Enable x86 ASM CPU cores" ${ASM_CORE_DEFAULT})
|
||||
|
@ -54,6 +58,14 @@ ENDIF()
|
|||
|
||||
option(ENABLE_FFMPEG "Enable ffmpeg A/V recording" ${FFMPEG_DEFAULT})
|
||||
|
||||
SET(LTO_DEFAULT ON)
|
||||
|
||||
IF(AMD64 AND WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(LTO_DEFAULT OFF)
|
||||
ENDIF()
|
||||
|
||||
OPTION(ENABLE_LTO "Compile with Link Time Optimization (gcc and clang only)" ${LTO_DEFAULT})
|
||||
|
||||
option( ENABLE_GBA_LOGGING "Enable extended GBA logging" ON )
|
||||
if( ENABLE_GBA_LOGGING )
|
||||
ADD_DEFINITIONS (-DGBA_LOGGING )
|
||||
|
@ -138,9 +150,7 @@ IF(APPLE)
|
|||
ENDIF(APPLE)
|
||||
|
||||
# We do not support amd64 asm yet
|
||||
IF((ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS OR ENABLE_MMX)
|
||||
AND CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86|[aA][mM][dD]64|[xX]64"
|
||||
AND CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
IF(AMD64 AND (ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS OR ENABLE_MMX))
|
||||
MESSAGE(FATAL_ERROR "The options ASM_CORE, ASM_SCALERS and MMX are not supported on AMD64 yet.")
|
||||
ENDIF()
|
||||
|
||||
|
@ -291,11 +301,14 @@ ENDIF()
|
|||
# Compiler flags
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(LTO_FLAG -flto=10)
|
||||
ELSE()
|
||||
SET(LTO_FLAG -flto)
|
||||
ENDIF()
|
||||
SET(LTO_FLAG "")
|
||||
IF(ENABLE_LTO)
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(LTO_FLAG -flto=10)
|
||||
ELSE()
|
||||
SET(LTO_FLAG -flto)
|
||||
ENDIF()
|
||||
ENDIF(ENABLE_LTO)
|
||||
|
||||
# common optimization flags
|
||||
SET(MY_C_AND_CXX_OPT_FLAGS -O2 -mtune=generic -fomit-frame-pointer ${LTO_FLAG})
|
||||
|
@ -385,7 +398,7 @@ ELSEIF("${CMAKE_SYSTEM}" MATCHES "Linux")
|
|||
ADD_DEFINITIONS(-DELF)
|
||||
ENDIF()
|
||||
|
||||
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86|[aA][mM][dD]64|[xX]64" AND CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
IF(AMD64)
|
||||
ADD_DEFINITIONS(-D__AMD64__)
|
||||
ENDIF()
|
||||
|
||||
|
|
Loading…
Reference in New Issue