From f9640e049d75b9d5416861a8b91f3fcd4c01cf1f Mon Sep 17 00:00:00 2001 From: Cheng Date: Sat, 14 Dec 2024 12:50:39 +0900 Subject: [PATCH] Install mlx.dll into the same dir with python bindings on Windows (#1690) * Install mlx.dll into the same dir with python bindings on Windows * Set BUILD_SHARED_LIBS for dlfcn-win32 * Update cmake requirements to 3.25 * Fix cmake style --- CMakeLists.txt | 10 ++++++++-- docs/src/install.rst | 2 +- examples/extensions/pyproject.toml | 2 +- examples/extensions/requirements.txt | 2 +- pyproject.toml | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff3df8aa6..5fc960b5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.24) +cmake_minimum_required(VERSION 3.25) project(mlx LANGUAGES C CXX) @@ -126,7 +126,10 @@ if(WIN32) GIT_REPOSITORY https://github.com/dlfcn-win32/dlfcn-win32.git GIT_TAG v1.4.1 EXCLUDE_FROM_ALL) + block() + set(BUILD_SHARED_LIBS OFF) FetchContent_MakeAvailable(dlfcn-win32) + endblock() target_include_directories(mlx PRIVATE "${dlfcn-win32_SOURCE_DIR}/src") target_link_libraries(mlx PRIVATE dl) endif() @@ -264,7 +267,10 @@ install( EXPORT MLXTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + RUNTIME + DESTINATION + # On Windows, DLLs must be put in the same dir with the python bindings. + $,${CMAKE_INSTALL_PREFIX},${CMAKE_INSTALL_BINDIR}> INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/docs/src/install.rst b/docs/src/install.rst index 1566d1f2c..5b9e93216 100644 --- a/docs/src/install.rst +++ b/docs/src/install.rst @@ -53,7 +53,7 @@ Build Requirements ^^^^^^^^^^^^^^^^^^ - A C++ compiler with C++17 support (e.g. Clang >= 5.0) -- `cmake `_ -- version 3.24 or later, and ``make`` +- `cmake `_ -- version 3.25 or later, and ``make`` - Xcode >= 15.0 and macOS SDK >= 14.0 .. note:: diff --git a/examples/extensions/pyproject.toml b/examples/extensions/pyproject.toml index 04690004b..5393fe35b 100644 --- a/examples/extensions/pyproject.toml +++ b/examples/extensions/pyproject.toml @@ -1,7 +1,7 @@ [build-system] requires = [ "setuptools>=42", - "cmake>=3.24", + "cmake>=3.25", "mlx>=0.18.0", "nanobind==2.2.0", ] diff --git a/examples/extensions/requirements.txt b/examples/extensions/requirements.txt index 0721663b9..084b049ce 100644 --- a/examples/extensions/requirements.txt +++ b/examples/extensions/requirements.txt @@ -1,4 +1,4 @@ setuptools>=42 -cmake>=3.24 +cmake>=3.25 mlx>=0.21.0 nanobind==2.2.0 diff --git a/pyproject.toml b/pyproject.toml index 8f3c66379..7fac87b94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,6 @@ requires = [ "setuptools>=42", "nanobind==2.2.0", - "cmake>=3.24", + "cmake>=3.25", ] build-backend = "setuptools.build_meta"