From 8a093a00ec402988b1784fcff1b2fc3b48c38298 Mon Sep 17 00:00:00 2001 From: Jakub Sujak Date: Mon, 8 Jul 2024 13:18:01 +0100 Subject: [PATCH] Add CMake build instructions * Add instructions for building for various platforms using CMake. * Provide a CMake toolchain file for Arm GNU Toolchain. Signed-off-by: Jakub Sujak --- README.md | 41 +++++++++++++++++++ .../aarch64-none-linux-gnu.toolchain.cmake | 15 +++++++ 2 files changed, 56 insertions(+) create mode 100644 cmake/toolchains/aarch64-none-linux-gnu.toolchain.cmake diff --git a/README.md b/README.md index f480734b..b4730790 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,47 @@ Some of the data types currently supported with the KleidiAI library are the fol +

How to build

+ +

Prerequisites

+ +KleidiAI requires the following dependencies, obtainable via your preferred package manager, to be installed and available on your system to be able to build the project. + +- `build-essential` +- `cmake >= 3.18` + +In addition, you may choose to use the following toolchains: + +- (Optional) `Arm GNU toolchain` available to download from the [Arm Developer](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) website. +- (Optional) `Android NDK` available to download from the [Android Developer](https://developer.android.com/ndk/downloads/index.html) website. + +

Compile natively on an Arm®-based system

+ +You can quickly compile KleidiAI on your system with an Arm® processor by using the following commands: + +```shell +cmake -DCMAKE_BUILD_TYPE=Release -S . -B build/ +cmake --build ./build +``` + +

Cross-compile to Android™

+ +Cross-compiling for Android systems requires the Android NDK toolset. The downloaded NDK contains the CMake toolchain file necessary for cross-compiling the project and must be provided to CMake with the `-DCMAKE_TOOLCHAIN_FILE` option. + +```shell +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -S . -B build/ +cmake --build ./build +``` + +

Cross-compile to Linux®

+ +The Arm GNU toolchain can be used to cross-compile to a Linux system with an Arm® processor like a Raspberry Pi from an x86_64 Linux host machine. Ensure the toolchain is available on your PATH and provide to CMake the Arm GNU Toolchain CMakefile found in `cmake/toolchains` directory with the `-DCMAKE_TOOLCHAIN_FILE` option. + +```shell +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/aarch64-none-linux-gnu.toolchain.cmake -S . -B build/ +cmake --build ./build +``` +

Release Cadence

The release is a tagged version of the source code. After the first official release (v0.1.0), releases will be made at least once every 3 months. The goal is a predictable and shorter time span between the releases. Until that point is diff --git a/cmake/toolchains/aarch64-none-linux-gnu.toolchain.cmake b/cmake/toolchains/aarch64-none-linux-gnu.toolchain.cmake new file mode 100644 index 00000000..83843084 --- /dev/null +++ b/cmake/toolchains/aarch64-none-linux-gnu.toolchain.cmake @@ -0,0 +1,15 @@ +# +# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 +# + +# The Arm GNU Toolchain is available for download from Arm Developer. +# https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(CMAKE_CROSSCOMPILING TRUE) + +set(CMAKE_C_COMPILER aarch64-none-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER aarch64-none-linux-gnu-g++) -- GitLab