chore: Use mold when available without option (#2521)

This commit is contained in:
Ayaz Salikhov
2025-09-04 16:03:05 +01:00
committed by GitHub
parent b8c298b734
commit a62084a4f0
4 changed files with 10 additions and 15 deletions

View File

@@ -1,8 +1,11 @@
if (use_mold)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS "Using Mold linker")
set(CMAKE_LINKER_TYPE MOLD)
else ()
message(FATAL_ERROR "Mold linker is only supported on Linux.")
endif ()
if (DEFINED CMAKE_LINKER_TYPE)
message(STATUS "Custom linker is already set: ${CMAKE_LINKER_TYPE}")
return()
endif ()
find_program(MOLD_PATH mold)
if (MOLD_PATH AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS "Using Mold linker: ${MOLD_PATH}")
set(CMAKE_LINKER_TYPE MOLD)
endif ()