Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ option(MLX_BUILD_SAFETENSORS "Include support for safetensors format" ON)
option(MLX_BUILD_PYTHON_STUBS "Build stub files for python bindings" ON)
option(MLX_METAL_JIT "Use JIT compilation for Metal kernels" OFF)
option(MLX_USE_CCACHE "Use CCache for compilation cache when available" ON)
option(MLX_EXPORT_ALL_SYMBOLS "Export all symbols in the library" OFF)
option(BUILD_SHARED_LIBS "Build mlx as a shared library" OFF)
option(USE_SYSTEM_FMT "Use system's provided fmt library" OFF)
option(USE_ASAN "Enable AddressSanitizer (ASan)" OFF)
Expand Down
20 changes: 14 additions & 6 deletions examples/extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
option(BUILD_SHARED_LIBS "Build extensions as a shared library" ON)

# ----------------------------- Dependencies -----------------------------

include(FetchContent)

# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
cmake_policy(SET CMP0135 NEW)

find_package(
Python 3.8
Python 3.10
COMPONENTS Interpreter Development.Module
REQUIRED)
execute_process(
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE nanobind_ROOT)
find_package(nanobind CONFIG REQUIRED)
FetchContent_Declare(
nanobind
GIT_REPOSITORY https://github.com/wjakob/nanobind.git
GIT_TAG v2.15.0
GIT_SHALLOW TRUE
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(nanobind)

execute_process(
COMMAND "${Python_EXECUTABLE}" -m mlx --cmake-dir
Expand Down
3 changes: 1 addition & 2 deletions examples/extensions/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
requires = [
"setuptools>=42",
"cmake>=3.25",
"mlx>=0.18.0",
"nanobind==2.15.0",
"mlx>=0.31.2",
]
build-backend = "setuptools.build_meta"
1 change: 0 additions & 1 deletion examples/extensions/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
setuptools>=42
cmake>=3.25
mlx>=0.31.2
nanobind==2.15.0
12 changes: 7 additions & 5 deletions mlx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ target_include_directories(mlx_version PRIVATE ${PROJECT_SOURCE_DIR})
target_link_libraries(mlx PRIVATE $<BUILD_INTERFACE:mlx_version>)

# Do not export symbols by default.
set_target_properties(
mlx mlx_version
PROPERTIES VISIBILITY_INLINES_HIDDEN ON
CXX_VISIBILITY_PRESET hidden
CUDA_VISIBILITY_PRESET hidden)
if(NOT MLX_EXPORT_ALL_SYMBOLS)
set_target_properties(
mlx mlx_version
PROPERTIES VISIBILITY_INLINES_HIDDEN ON
CXX_VISIBILITY_PRESET hidden
CUDA_VISIBILITY_PRESET hidden)
endif()

# Define MLX_EXPORT for shared libraries, MLX_STATIC for static libraries.
set_target_properties(mlx PROPERTIES DEFINE_SYMBOL MLX_EXPORT)
Expand Down
Loading