2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-22 01:47:45 +01:00

cmake: add more release optimization flags.

This commit is contained in:
Andrey Akhmichin 2024-01-15 08:55:36 +05:00
parent 86c00428f5
commit 554dc51472
2 changed files with 22 additions and 0 deletions

View File

@ -36,6 +36,17 @@ if(NOT MSVC)
if(NOT MINGW)
add_definitions(-D_snprintf=snprintf -D_vsnprintf=vsnprintf)
endif()
if(CMAKE_BUILD_TYPE MATCHES "Release"
OR (CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo"
AND CMAKE_SYSTEM_NAME STREQUAL "Android"))
add_compile_options(-fno-unwind-tables -fno-asynchronous-unwind-tables) # GCC/Clang flag
add_compile_options(-fomit-frame-pointer) # GCC/Clang flag
add_compile_options(-ftree-vectorize) # GCC/Clang flag
add_compile_options(-funsafe-math-optimizations) # GCC/Clang flag
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
add_compile_options(-O3 -DNDEBUG) # gradle compiles release builds with RelWithDebInfo(-O2 -g) and strips debug symbols.
endif()
endif()
else()
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
endif()

View File

@ -32,6 +32,17 @@ if(NOT MSVC)
add_compile_options(-fvisibility=hidden) # GCC/Clang flag
add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems
add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf )
if(CMAKE_BUILD_TYPE MATCHES "Release"
OR (CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo"
AND CMAKE_SYSTEM_NAME STREQUAL "Android"))
add_compile_options(-fno-unwind-tables -fno-asynchronous-unwind-tables) # GCC/Clang flag
add_compile_options(-fomit-frame-pointer) # GCC/Clang flag
add_compile_options(-ftree-vectorize) # GCC/Clang flag
add_compile_options(-funsafe-math-optimizations) # GCC/Clang flag
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
add_compile_options(-O3 -DNDEBUG) # gradle compiles release builds with RelWithDebInfo(-O2 -g) and strips debug symbols.
endif()
endif()
else()
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
endif()