From 2c7b4f30c6c06b9025e7ec0c6fae4269822f8b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 17 Oct 2023 18:43:20 +0300 Subject: [PATCH] Add USE_ALTERNATE_LINKER to cache if available --- CMakeLists.txt | 2 +- cmake/modules/linker.cmake | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 802839dac7f..ce92dadf662 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -783,7 +783,7 @@ if(ENABLE_COVERAGE) SETUP_TARGET_FOR_COVERAGE(qgis_coverage ctest coverage) endif() -if(USE_ALTERNATE_LINKER) +if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) include("cmake/modules/linker.cmake") endif() diff --git a/cmake/modules/linker.cmake b/cmake/modules/linker.cmake index 7e093ae241a..28c4730d646 100644 --- a/cmake/modules/linker.cmake +++ b/cmake/modules/linker.cmake @@ -31,12 +31,10 @@ macro(set_alternate_linker linker) endif() endmacro() -if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) - set(USE_ALTERNATE_LINKER "" CACHE STRING "Use alternate linker. Leave empty for system default; potential alternatives are 'gold', 'lld', 'bfd', 'mold'") - if(NOT "${USE_ALTERNATE_LINKER}" STREQUAL "") - set_alternate_linker(${USE_ALTERNATE_LINKER}) - endif() - set(USE_ALTERNATE_LINKER_OLD_CACHED - ${USE_ALTERNATE_LINKER} - CACHE INTERNAL "Previous value of USE_ALTERNATE_LINKER") +set(USE_ALTERNATE_LINKER "" CACHE STRING "Use alternate linker. Leave empty for system default; potential alternatives are 'gold', 'lld', 'bfd', 'mold'") +if(NOT "${USE_ALTERNATE_LINKER}" STREQUAL "") + set_alternate_linker(${USE_ALTERNATE_LINKER}) endif() +set(USE_ALTERNATE_LINKER_OLD_CACHED + ${USE_ALTERNATE_LINKER} + CACHE INTERNAL "Previous value of USE_ALTERNATE_LINKER")