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# Set the minimum required version of CMake for this project. 8cmake_minimum_required(VERSION 3.10) 9 10if(NOT CMAKE_CXX_STANDARD) 11 set(CMAKE_CXX_STANDARD 17) 12endif() 13 14# Set the project name. 15project(cadence_backend) 16 17# Source root directory for executorch. 18if(NOT EXECUTORCH_ROOT) 19 set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) 20endif() 21 22include(${EXECUTORCH_ROOT}/build/Utils.cmake) 23 24# Let files say "include <executorch/path/to/header.h>". 25set(_common_include_directories ${EXECUTORCH_ROOT}/..) 26set(TARGET_DIR reference) 27 28if(EXECUTORCH_CADENCE_CPU_RUNNER) 29 include(${EXECUTORCH_ROOT}/build/Codegen.cmake) 30 31 if(NOT PYTHON_EXECUTABLE) 32 resolve_python_executable() 33 endif() 34 35 set(_common_compile_options -Wno-deprecated-declarations -fPIC) 36 37 # Find prebuilt libraries. executorch package should contain portable_ops_lib, 38 # etdump, bundled_program. 39 find_package(executorch CONFIG REQUIRED) 40 target_link_options_shared_lib(executorch) 41 target_link_options_shared_lib(portable_ops_lib) 42 43 target_include_directories(executorch INTERFACE ${_common_include_directories}) 44 45 find_package( 46 gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../third-party 47 ) 48 49 add_executable(cadence_runner 50 ${EXECUTORCH_ROOT}/examples/devtools/example_runner/example_runner.cpp 51 ) 52 target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED) 53 54 target_include_directories( 55 etdump INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../devtools/include 56 ${EXECUTORCH_ROOT}/third-party/flatcc/include 57 ) 58 59 target_include_directories( 60 cadence_runner PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR} 61 ${_common_include_directories} 62 ) 63 64 target_link_libraries( 65 cadence_runner 66 executorch 67 gflags 68 etdump 69 extension_data_loader 70 bundled_program 71 cadence_ops_lib 72 flatccrt 73 ) 74endif() 75 76if(EXECUTORCH_NNLIB_OPT) 77 set(TARGET_DIR hifi) 78 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib) 79endif() 80 81add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/operators) 82add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/kernels) 83