From 663fe5a4bd1a3cc7d0f65d19147a387cea0684a4 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 1 Mar 2015 15:29:57 +0100 Subject: [PATCH] Add --gc-sections to the linker flags --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78a081cec..aff346be0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,11 +129,14 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -pthread") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lpthread") else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") endif() + + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections") endif() if(MSVC)