From 9f0641ffe82c3d9f94c5e2b7acf02a9b767ea36b Mon Sep 17 00:00:00 2001 From: Rafael Palomar Date: Fri, 27 Oct 2023 10:24:41 +0200 Subject: [PATCH] ENH: Enable propagation of linker flags This change allows customizing the linker flags at the superbuild level. The motivation behind this modification was to enable the use of the gold linker in 3D Slicer, as referenced in https://github.com/Slicer/Slicer/pull/7294, to expedite the linking phase during the build process. Co-authored-by: Jean-Christophe Fillion-Robin --- CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2777f6a52..a11c75e455 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -357,6 +357,25 @@ set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags") mark_as_advanced(ADDITIONAL_CXX_FLAGS) mark_as_superbuild(ADDITIONAL_CXX_FLAGS) +#----------------------------------------------------------------------------- +# Linker flags +# +# This section is adapted to enhance the build process by introducing the +# possibility of customizing linker flags. This was added in connection with +# enabling the gold linker in 3D Slicer, as outlined in PR: +# https://github.com/Slicer/Slicer/pull/7294. +# +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Flags used by the linker" FORCE) +set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}" CACHE STRING "Flags used by the linker (module)" FORCE) +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" CACHE STRING "Flags used by the linker (shared)" FORCE) + +mark_as_superbuild(VARS + CMAKE_EXE_LINKER_FLAGS:STRING + CMAKE_MODULE_LINKER_FLAGS:STRING + CMAKE_SHARED_LINKER_FLAGS:STRING + ALL_PROJECTS +) + #----------------------------------------------------------------------------- # Set symbol visibility Flags #