summaryrefslogtreecommitdiff
path: root/CMake/CompilerFlags.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'CMake/CompilerFlags.cmake')
-rw-r--r--CMake/CompilerFlags.cmake6
1 files changed, 6 insertions, 0 deletions
diff --git a/CMake/CompilerFlags.cmake b/CMake/CompilerFlags.cmake
index efc6a328..06591435 100644
--- a/CMake/CompilerFlags.cmake
+++ b/CMake/CompilerFlags.cmake
@@ -99,6 +99,12 @@ if (NOT APPLE)
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")
endif (NOT APPLE)
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ # Only some distributions' GCC (Ubuntu's) links --as-needed by default;
+ # without it a program loads every library its static dependencies link,
+ # used or not.
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
+endif ()
#