Added CMake option for native optimizations (-march=native)

Signed-off-by: Gabriel Ravier <gabrielravier@gabrielAncientIBMv2>
This commit is contained in:
Gabriel Ravier 2020-01-29 19:30:18 +01:00 committed by Gabriel Ravier
parent 1442299924
commit d88db09752
2 changed files with 14 additions and 0 deletions

View file

@ -16,6 +16,8 @@ option(DEBUG_SAVE "Re-enable the ability to drag-and-drop save files onto the wi
set(RENDERER "SDLTexture" CACHE STRING "Which renderer the game should use: 'OpenGL3' for an OpenGL 3.2 renderer, 'OpenGLES2' for an OpenGL ES 2.0 renderer, 'SDLTexture' for SDL2's hardware-accelerated Texture API, 'SDLSurface' for SDL2's software-rendered Surface API, or 'Software' for a handwritten software renderer")
option(LTO "Enable link-time optimisation" OFF)
option(NATIVE_OPTIMIZATIONS "Enable processor-specific optimisations (executable might not work on other architectures) (GCC-compatible compilers only)" OFF)
option(WARNINGS "Enable common compiler warnings (for GCC-compatible compilers and MSVC only)" OFF)
option(WARNINGS_ALL "Enable ALL compiler warnings (for Clang and MSVC only)" OFF)
option(WARNINGS_FATAL "Stop compilation on any compiler warning (for GCC-compatible compilers and MSVC only)" OFF)
@ -450,6 +452,17 @@ if(LTO)
endif()
endif()
# Enable -march=native if available
if(NATIVE_OPTIMIZATIONS)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
target_compile_options(CSE2 PRIVATE -march=native)
else()
message(WARNING "Couldn't activate native optimizations ! (Unsupported compiler)")
endif()
endif()
# Find dependencies
if(NOT FORCE_LOCAL_LIBS)

View file

@ -61,6 +61,7 @@ You can also add the following flags:
Name | Function
--------|--------
`-DLTO=ON` | Enable link-time optimisation
`-DNATIVE_OPTIMIZATIONS=ON` | Enable processor-specific optimisations (executable might not work on other architectures) (GCC-compatible compilers only)
`-DJAPANESE=ON` | Enable the Japanese-language build (instead of the unofficial Aeon Genesis English translation)
`-DFIX_BUGS=ON` | Fix various bugs in the game
`-DDEBUG_SAVE=ON` | Re-enable the ability to drag-and-drop save files onto the window