CMake: Add option to compress debug sections using -gz if possible

This commit is contained in:
Jonathan G Rennison
2023-02-20 17:44:54 +00:00
parent 5efe3a8b5b
commit c1532107fc

View File

@@ -170,6 +170,17 @@ macro(compile_flags)
endif()
endif()
if(OPTION_COMPRESS_DEBUG)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-gz" GZ_FOUND)
if(GZ_FOUND)
# Compress debug sections.
add_compile_options(-gz)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -gz")
endif()
endif(OPTION_COMPRESS_DEBUG)
if (OPTION_NO_WARN_UNINIT)
add_compile_options(-Wno-maybe-uninitialized -Wno-uninitialized)
endif (OPTION_NO_WARN_UNINIT)