From 554dc51472e69686409cc83b616a21a42216d817 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Mon, 15 Jan 2024 08:55:36 +0500 Subject: [PATCH] cmake: add more release optimization flags. --- cl_dll/CMakeLists.txt | 11 +++++++++++ dlls/CMakeLists.txt | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index acf5aafa..cc40c27e 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -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() diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 2530e508..82460492 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -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()