Skip to content

Instantly share code, notes, and snippets.

@awni
Last active January 24, 2025 14:39
Show Gist options
  • Save awni/112ff52290e6b7602183d1e6a809166f to your computer and use it in GitHub Desktop.
Save awni/112ff52290e6b7602183d1e6a809166f to your computer and use it in GitHub Desktop.
Minimal MLX CMake
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)
#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;
}
@awni
Copy link
Author

awni commented Oct 17, 2024

The documentation has more details on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment