Last active
October 23, 2024 22:00
-
-
Save awni/112ff52290e6b7602183d1e6a809166f to your computer and use it in GitHub Desktop.
Minimal MLX CMake
This file contains 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(_ext LANGUAGES CXX) | |
# ----------------------------- Setup ----------------------------- | |
set(CMAKE_CXX_STANDARD 17) | |
set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | |
option(BUILD_SHARED_LIBS "Build as a shared library" ON) | |
# ----------------------------- Dependencies ----------------------------- | |
find_package(MLX CONFIG REQUIRED) | |
add_executable(main main.cpp) | |
target_link_libraries(main PUBLIC mlx) |
This file contains 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> | |
using namespace mlx::core; | |
int main () { | |
auto a = 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
To build you should have MLX installed. If you installed it with Python you can do something like this: