CMake: Add QTC_USE_LLVM_LINKER option

llvm-link is faster on macOS than ld64. llvm-link can also be used with
MinGW GCC's ld which is very slow in debug mode.

Change-Id: Ie519f3111e05cfc7dffab2676108a0d53ebe08b2
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Cristian Adam
2024-01-08 14:40:56 +01:00
parent a14cd5d702
commit edb8b0aeb7
3 changed files with 11 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
qtc_handle_compiler_cache_support()
qtc_handle_llvm_linker()
option(BUILD_LINK_WITH_QT "Link with Qt from the parent Qt Creator" OFF)
qtc_link_with_qt()

View File

@@ -46,6 +46,7 @@ option(QTC_SEPARATE_DEBUG_INFO "Extract debug information from binary files." OF
option(WITH_SCCACHE_SUPPORT "Enables support for building with SCCACHE and separate debug info with MSVC, which SCCACHE normally doesn't support." OFF)
option(WITH_CCACHE_SUPPORT "Enables support for building with CCACHE and separate debug info with MSVC, which CCACHE normally doesn't support." "${ENV_WITH_CCACHE_SUPPORT}")
option(QTC_STATIC_BUILD "Builds libraries and plugins as static libraries" OFF)
option(QTC_USE_LLVM_LINKER "Uses llvm-link linker if found." OFF)
# If we provide a list of plugins, executables, libraries, then the BUILD_<type>_BY_DEFAULT will be set to OFF
# and for every element we set BUILD_<type>_<elment> to ON

View File

@@ -141,6 +141,15 @@ function(qtc_handle_compiler_cache_support)
endif()
endfunction()
function(qtc_handle_llvm_linker)
if (QTC_USE_LLVM_LINKER)
find_program(LLVM_LINK_PROGRAM llvm-link)
if(LLVM_LINK_PROGRAM)
set(CMAKE_LINKER "${LLVM_LINK_PROGRAM}" CACHE STRING "LLVM linker" FORCE)
endif()
endif()
endfunction()
function(qtc_link_with_qt)
# When building with Qt Creator 4.15+ do the "Link with Qt..." automatically
if (BUILD_LINK_WITH_QT AND DEFINED CMAKE_PROJECT_INCLUDE_BEFORE)