diff --git a/CMakeLists.txt b/CMakeLists.txt index 39185e6..a6d1ff6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,10 @@ if (${IS_GNU} OR ${IS_CLANG}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstrict-enums -pipe -funwind-tables -fasynchronous-unwind-tables -frtti -fexceptions") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections -fmerge-all-constants -ftree-vectorize -fno-math-errno") include(CheckCXXCompilerFlag) + check_cxx_compiler_flag("-Oz" Z_OPTIMIZATION_SUPPORTED) + if (Z_OPTIMIZATION_SUPPORTED) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Oz") + endif() set(CF_PROTECTION "-fcf-protection") check_cxx_compiler_flag("${CF_PROTECTION}" CF_PROTECTION_SUPPORTED) if (CF_PROTECTION_SUPPORTED)