Getting Started on Linux with CMake

Prerequisites

Install CMake

Install CMake version >= 3.13:

$ sudo apt install cmake

Tip:
    Your editor of choice likely has plugins for CMake, such as the Visual Studio Code CMake Tools extension.

Install a Compiler

We recommend Clang. GCC is not fully supported.

$ sudo apt install clang

Set environment variables:

export CC=clang
export CXX=clang++

Clone and Build

Clone

Clone the repository and initialize its submodules:

$ git clone https://github.com/google/iree.git
$ cd iree
$ git submodule update --init

Tip:
    Editors and other programs can also clone the repository, just make sure that they initialize the submodules.

Build

Configure:

$ cmake -B build/ .

Tip:
    The root CMakeLists.txt file has options for configuring which parts of the project to enable.

Build all targets:

$ cmake --build build/ -j 8

What's next?

Take a Look Around

Check out the contents of the ‘tools’ build directory:

$ ls build/iree/tools
$ ./build/iree/tools/iree-translate --help

Translate a MLIR file and execute a function in the compiled module:

$ ./build/iree/tools/iree-run-mlir $PWD/iree/tools/test/simple.mlir -input-value="i32=-2" -iree-hal-target-backends=vmla -print-mlir

Further Reading

More documentation coming soon...