From a2c1b64552aa3ad384fe6019b43330fbe6456a5b Mon Sep 17 00:00:00 2001 From: gradient Date: Fri, 20 Oct 2017 11:27:17 -0500 Subject: [PATCH] ld.gold notes --- CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a2001f..d5eb64b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,25 @@ project(zinnia VERSION 0.1 LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 17) +# ## Thanks to yipdw/ninjawedding for this snippet: https://gitlab.peach-bun.com/snippets/103 +# If ld.gold is available, use it -- it's faster. Also enable incremental +# linking for debug and release. + +# TODO: It's probably a good idea to enable -z relro for non-development +# builds. That's more CMake archaeology, though, and I'm not really in the +# mood for that now. +# option(USE_LD_GOLD "Use GNU gold linker" ON) +# execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) +# if(USE_LD_GOLD) +# execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) +# if("${LD_VERSION}" MATCHES "GNU gold") +# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,-z,norelro -Wl,--incremental") +# else() +# message(WARNING "GNU gold linker isn't available, using the default system linker.") +# endif() +# endif() + + find_package(PkgConfig REQUIRED) find_package(OpenGL REQUIRED) pkg_check_modules(GTK3 REQUIRED gtk+-3.0)