Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix library output directory for MSVC #1681

Merged
merged 1 commit into from
Dec 10, 2024
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
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
15 changes: 13 additions & 2 deletions python/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,19 @@ 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})
set_target_properties(
core
PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${MLX_PYTHON_BINDINGS_OUTPUT_DIRECTORY}
# Do not append a sub-dir for multi-config generators like MSVC
# and XCode.
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})

target_link_libraries(core PRIVATE mlx)
target_compile_definitions(core PRIVATE _VERSION_=${MLX_VERSION})
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def build_extension(self, ext: CMakeExtension) -> None:
"-DMLX_BUILD_EXAMPLES=OFF",
f"-DMLX_PYTHON_BINDINGS_OUTPUT_DIRECTORY={extdir}{os.sep}",
]
build_args = []
# Some generators require explcitly passing config when building.
build_args = ["--config", cfg]
# Adding CMake arguments set as environment variable
# (needed e.g. to build for ARM OSx on conda-forge)
if "CMAKE_ARGS" in os.environ:
Expand Down