Last active
January 24, 2025 14:39
-
-
Save awni/112ff52290e6b7602183d1e6a809166f to your computer and use it in GitHub Desktop.
Minimal MLX CMake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.27) | |
project(example LANGUAGES CXX) | |
set(CMAKE_CXX_STANDARD 17) | |
set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
find_package( | |
Python 3.9 | |
COMPONENTS Interpreter Development.Module | |
REQUIRED) | |
execute_process( | |
COMMAND "${Python_EXECUTABLE}" -m mlx --cmake-dir | |
OUTPUT_STRIP_TRAILING_WHITESPACE | |
OUTPUT_VARIABLE MLX_ROOT) | |
find_package(MLX CONFIG REQUIRED) | |
add_executable(main main.cpp) | |
target_link_libraries(main PRIVATE mlx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <mlx/mlx.h> | |
namespace mx = mlx::core; | |
int main () { | |
auto a = mx::array({1,2,3}); | |
std::cout << a << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The documentation has more details on this.