From 7d86a5c108e5fd3107771f47bfc7fef7e15b8d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Tue, 5 Aug 2025 01:36:11 +0200 Subject: [PATCH] Feat: add USE_SYSTEM_FMT CMake option (#2219) --- CMakeLists.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ed41aea5c..b4ebba2c38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ option(MLX_BUILD_BLAS_FROM_SOURCE "Build OpenBLAS from source code" OFF) option(MLX_METAL_JIT "Use JIT compilation for Metal kernels" OFF) option(MLX_USE_CCACHE "Use CCache for compilation cache when available" ON) option(BUILD_SHARED_LIBS "Build mlx as a shared library" OFF) +option(USE_SYSTEM_FMT "Use system's provided fmt library" OFF) # --------------------- Processor tests ------------------------- message( @@ -242,12 +243,16 @@ target_include_directories( # Do not add mlx_EXPORTS define for shared library. set_target_properties(mlx PROPERTIES DEFINE_SYMBOL "") -FetchContent_Declare( - fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt.git - GIT_TAG 10.2.1 - EXCLUDE_FROM_ALL) -FetchContent_MakeAvailable(fmt) +if(USE_SYSTEM_FMT) + find_package(fmt REQUIRED) +else() + FetchContent_Declare( + fmt + GIT_REPOSITORY https://github.com/fmtlib/fmt.git + GIT_TAG 10.2.1 + EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(fmt) +endif() target_link_libraries(mlx PRIVATE $) if(MLX_BUILD_PYTHON_BINDINGS)