Skip to content
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
94 changes: 94 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

env:
BUILD_TYPE: Release
CMAKE_POLICY_VERSION_MINIMUM: 3.5
MLX_REF: v0.31.1

jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
- name: Ubuntu
os: ubuntu-24.04
cc: clang
cxx: clang++
mlx_args: -DMLX_BUILD_CPU=ON -DMLX_BUILD_METAL=OFF -DMLX_BUILD_CUDA=OFF
- name: macOS
os: macos-14
cc: clang
cxx: clang++
mlx_args: -DMLX_BUILD_CPU=ON -DMLX_BUILD_METAL=ON -DMLX_BUILD_CUDA=OFF

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install Ubuntu dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
clang \
cmake \
libblas-dev \
liblapack-dev \
liblapacke-dev \
ninja-build \
zlib1g-dev

- name: Install macOS dependencies
if: runner.os == 'macOS'
run: brew install ninja

- name: Check out MLX
run: |
git clone --depth 1 --branch "$MLX_REF" https://github.com/ml-explore/mlx.git "$RUNNER_TEMP/mlx"

- name: Build and install MLX
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
cmake -S "$RUNNER_TEMP/mlx" -B "$RUNNER_TEMP/mlx-build" -G Ninja \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DCMAKE_INSTALL_PREFIX="$RUNNER_TEMP/mlx-install" \
-DMLX_BUILD_BENCHMARKS=OFF \
-DMLX_BUILD_EXAMPLES=OFF \
-DMLX_BUILD_PYTHON_BINDINGS=OFF \
-DMLX_BUILD_TESTS=OFF \
${{ matrix.mlx_args }}
cmake --build "$RUNNER_TEMP/mlx-build" --parallel
cmake --install "$RUNNER_TEMP/mlx-build"

- name: Configure project
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DCMAKE_POLICY_VERSION_MINIMUM="$CMAKE_POLICY_VERSION_MINIMUM" \
-DCMAKE_PREFIX_PATH="$RUNNER_TEMP/mlx-install"

- name: Build project
run: cmake --build build --parallel
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.27)
project(mlx_cpp LANGUAGES CXX C)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -69,7 +69,7 @@ target_compile_options(
-Wextra
-Wpedantic
-Werror
-Wnounused-const-variable
-Wno-unused-const-variable
-fsanitize=undefined
-fsanitize=address
-g)
Expand Down
Loading