Minimize Releaase Executable Sizes.

Use the  data-sections and function-sections gcc/g++  compiler options
to  create  sections  for  each   function  and  data  item  then  use
gc-sections in the link to discard all unreferenced sections.

This has most benefit if the hamlib library we statically link is also
compiled with data-sections and function-sections.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4351 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2014-09-24 17:25:38 +00:00
parent 30b50ff9e2
commit d30cbe4591

View File

@ -395,7 +395,13 @@ endif (APPLE)
# C & C++ setup
#
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fdata-sections -ffunction-sections")
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -fdata-sections -ffunction-sections")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++11 -fexceptions -frtti")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fdata-sections -ffunction-sections")
set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -fdata-sections -ffunction-sections")
if (WIN32)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-keep-inline-dllexport")
endif (WIN32)
@ -436,6 +442,13 @@ else (Fortran_COMPILER_NAME MATCHES "gfortran.*")
endif (Fortran_COMPILER_NAME MATCHES "gfortran.*")
#
# Linker setup
#
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -Wl,--gc-sections")
set (CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -Wl,--gc-sections")
#
# setup and test Fortran C/C++ interaction
#