Skip to content

Commit 84d2a1d

Browse files
committed
nits
1 parent 351ee54 commit 84d2a1d

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

‎backends/mlx/CMakeLists.txt‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ ExternalProject_Add(
206206
# MLX's own install() does not emit libmlx.a where we consume it or the
207207
# metallib at all, so skip the install step and read both from the build tree.
208208
INSTALL_COMMAND ""
209+
# ExternalProject stamps its build, so a bare MLX submodule bump (git
210+
# submodule update) would not invalidate the stamp and we'd link a stale
211+
# libmlx.a with no signal. BUILD_ALWAYS reruns the build step every configure;
212+
# it is a fast no-op under Ninja when nothing changed.
213+
BUILD_ALWAYS ON
209214
# Required so Ninja knows these are produced by the external build.
210215
BUILD_BYPRODUCTS ${_mlx_static_lib} ${_mlx_metallib}
211216
)
@@ -217,7 +222,9 @@ ExternalProject_Add(
217222
add_library(mlx STATIC IMPORTED GLOBAL)
218223
set_target_properties(mlx PROPERTIES IMPORTED_LOCATION ${_mlx_static_lib})
219224
# Headers come from the submodule source tree (always present), not the build
220-
# dir, so mlxdelegate compilation cannot race the external build.
225+
# dir, so mlxdelegate compilation cannot race the external build. Verified: MLX
226+
# emits no public headers into the build tree (version.h is checked in; the
227+
# version string is a compile-def on version.cpp), so the source dir suffices.
221228
target_include_directories(mlx INTERFACE ${MLX_SOURCE_DIR})
222229
find_library(METAL_FRAMEWORK Metal)
223230
find_library(FOUNDATION_FRAMEWORK Foundation)
@@ -227,7 +234,6 @@ set_target_properties(
227234
PROPERTIES INTERFACE_LINK_LIBRARIES
228235
"${METAL_FRAMEWORK};${FOUNDATION_FRAMEWORK};${QUARTZ_FRAMEWORK}"
229236
)
230-
add_dependencies(mlx mlx_external)
231237

232238
# -----------------------------------------------------------------------------
233239
# MLX Backend library
@@ -255,9 +261,8 @@ add_library(mlxdelegate ${_mlx_backend__srcs})
255261
# Ensure schema is generated before compiling
256262
add_dependencies(mlxdelegate mlx_schema)
257263

258-
# mlx is an imported target, so add_dependencies(mlx mlx_external) above does
259-
# not order the build. Depend on mlx_external directly so libmlx.a exists before
260-
# mlxdelegate links.
264+
# mlx is an imported target, so a dependency on it would not order the build.
265+
# Depend on mlx_external directly so libmlx.a exists before mlxdelegate links.
261266
add_dependencies(mlxdelegate mlx_external)
262267

263268
# Add logging flag if enabled

‎tools/cmake/executorch-config.cmake‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,23 @@ if(TARGET mlxdelegate)
134134
if(_mlx_library)
135135
add_library(mlx STATIC IMPORTED)
136136
set_target_properties(mlx PROPERTIES IMPORTED_LOCATION "${_mlx_library}")
137-
# MLX requires Metal and Foundation frameworks on Apple platforms
137+
# libmlx.a is a static archive with no transitive link deps, so re-add the
138+
# frameworks MLX links PUBLIC (mirrors
139+
# third-party/mlx/CMakeLists.txt:209). Must match the in-tree imported
140+
# target in backends/mlx/CMakeLists.txt.
138141
if(APPLE)
139142
find_library(METAL_FRAMEWORK Metal)
140143
find_library(FOUNDATION_FRAMEWORK Foundation)
141-
if(METAL_FRAMEWORK AND FOUNDATION_FRAMEWORK)
144+
find_library(QUARTZ_FRAMEWORK QuartzCore)
145+
if(METAL_FRAMEWORK
146+
AND FOUNDATION_FRAMEWORK
147+
AND QUARTZ_FRAMEWORK
148+
)
142149
set_target_properties(
143-
mlx PROPERTIES INTERFACE_LINK_LIBRARIES
144-
"${METAL_FRAMEWORK};${FOUNDATION_FRAMEWORK}"
150+
mlx
151+
PROPERTIES
152+
INTERFACE_LINK_LIBRARIES
153+
"${METAL_FRAMEWORK};${FOUNDATION_FRAMEWORK};${QUARTZ_FRAMEWORK}"
145154
)
146155
endif()
147156
endif()

0 commit comments

Comments
 (0)