From 14c6e60acb969537dc6637de079c005ed64d3ac2 Mon Sep 17 00:00:00 2001 From: Bob Cao Date: Sun, 13 Mar 2022 23:02:03 -0700 Subject: [PATCH] Also allow mold (requires GCC 12.1+ or Clang) --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 496c8d702ed93..180e6b867bd3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ if(CCACHE_PROGRAM) endif() option(USE_LLD "Use lld (from llvm) linker" OFF) +option(USE_MOLD "Use mold (A Modern Linker)" OFF) if (USE_LLD) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld") @@ -64,6 +65,12 @@ if (USE_LLD) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld") endif() +if (USE_MOLD) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=mold") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=mold") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=mold") +endif() + # No support of Python for Android build if (NOT ANDROID) include(cmake/PythonNumpyPybind11.cmake)