xref: /aosp_15_r20/external/executorch/examples/arm/CMakeLists.txt (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2# All rights reserved.
3#
4# This source code is licensed under the BSD-style license found in the
5# LICENSE file in the root directory of this source tree.
6
7# Kernel library for portable kernels. Please this file formatted by running:
8# ~~~
9# cmake-format -i CMakeLists.txt
10# ~~~
11
12cmake_minimum_required(VERSION 3.19)
13project(arm_example)
14
15# Option to register op list
16option(EXECUTORCH_SELECT_OPS_LIST "Register the following list of ops" OFF)
17
18set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
19# Source root directory for executorch.
20if(NOT EXECUTORCH_ROOT)
21  set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
22endif()
23
24include(${EXECUTORCH_ROOT}/build/Utils.cmake)
25
26if(NOT PYTHON_EXECUTABLE)
27  resolve_python_executable()
28endif()
29
30set(_common_compile_options -Wno-deprecated-declarations -fPIC)
31
32# Let files say "include <executorch/path/to/header.h>".
33set(_common_include_directories ${EXECUTORCH_ROOT}/..)
34
35find_package(executorch CONFIG REQUIRED HINTS ${CMAKE_INSTALL_PREFIX})
36target_include_directories(executorch INTERFACE ${_common_include_directories})
37
38include(${EXECUTORCH_ROOT}/build/Utils.cmake)
39include(${EXECUTORCH_ROOT}/build/Codegen.cmake)
40
41# Generate C++ bindings to register kernels into both PyTorch (for AOT) and
42# Executorch (for runtime). Here select all ops in functions.yaml
43gen_selected_ops(
44  LIB_NAME
45  "arm_portable_ops_lib"
46  OPS_SCHEMA_YAML
47  ""
48  ROOT_OPS
49  "${EXECUTORCH_SELECT_OPS_LIST}"
50  INCLUDE_ALL_OPS
51  ""
52)
53generate_bindings_for_kernels(
54  LIB_NAME "arm_portable_ops_lib" FUNCTIONS_YAML
55  ${EXECUTORCH_ROOT}/kernels/portable/functions.yaml
56)
57gen_operators_lib(
58  LIB_NAME "arm_portable_ops_lib" KERNEL_LIBS portable_kernels DEPS executorch
59)
60