Skip to content

Commit

Permalink
Fix library output directory for MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Dec 9, 2024
1 parent d0f471c commit f18056c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ build/
*.out
*.app

# Debug symbols
*.pdb

# VSCode
.vscode/
.DS_Store
Expand Down
17 changes: 15 additions & 2 deletions python/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,21 @@ if(NOT MLX_PYTHON_BINDINGS_OUTPUT_DIRECTORY)
set(MLX_PYTHON_BINDINGS_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
endif()

set_target_properties(core PROPERTIES LIBRARY_OUTPUT_DIRECTORY
${MLX_PYTHON_BINDINGS_OUTPUT_DIRECTORY})
if(MSVC)
set_target_properties(
core
PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE
${MLX_PYTHON_BINDINGS_OUTPUT_DIRECTORY}
LIBRARY_OUTPUT_DIRECTORY_DEBUG
${MLX_PYTHON_BINDINGS_OUTPUT_DIRECTORY}
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO
${MLX_PYTHON_BINDINGS_OUTPUT_DIRECTORY}
LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL
${MLX_PYTHON_BINDINGS_OUTPUT_DIRECTORY})
else()
set_target_properties(core PROPERTIES LIBRARY_OUTPUT_DIRECTORY
${MLX_PYTHON_BINDINGS_OUTPUT_DIRECTORY})
endif()

target_link_libraries(core PRIVATE mlx)
target_compile_definitions(core PRIVATE _VERSION_=${MLX_VERSION})
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def build_extension(self, ext: CMakeExtension) -> None:
# CMake 3.12+ only.
build_args += [f"-j{self.parallel}"]

# MSVC requires explcitly passing config when building.
if sys.platform in ["win32", "cygwin"]:
build_args += ["--config", cfg]

build_temp = Path(self.build_temp) / ext.name
if not build_temp.exists():
build_temp.mkdir(parents=True)
Expand Down

0 comments on commit f18056c

Please sign in to comment.