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 7cmake_minimum_required(VERSION 3.19) 8 9set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 10if(NOT CMAKE_CXX_STANDARD) 11 set(CMAKE_CXX_STANDARD 17) 12endif() 13 14# Source root directory for executorch. 15if(NOT EXECUTORCH_ROOT) 16 set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..) 17endif() 18 19include(${EXECUTORCH_ROOT}/build/Utils.cmake) 20 21if(NOT PYTHON_EXECUTABLE) 22 resolve_python_executable() 23endif() 24 25set(_common_compile_options -Wno-deprecated-declarations) 26 27include(${EXECUTORCH_ROOT}/build/Utils.cmake) 28include(${EXECUTORCH_ROOT}/build/Codegen.cmake) 29 30if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED) 31 # Merge optimized and portable definitions, taking optimized where available. 32 merge_yaml( 33 FUNCTIONS_YAML ${EXECUTORCH_ROOT}/kernels/optimized/optimized-oss.yaml 34 FALLBACK_YAML ${EXECUTORCH_ROOT}/kernels/portable/functions.yaml OUTPUT_DIR 35 ${CMAKE_CURRENT_BINARY_DIR} 36 ) 37 38 gen_selected_ops( 39 LIB_NAME "optimized_native_cpu_ops_lib" OPS_SCHEMA_YAML 40 "${CMAKE_CURRENT_BINARY_DIR}/merged.yaml" 41 ) 42 43 generate_bindings_for_kernels( 44 LIB_NAME "optimized_native_cpu_ops_lib" FUNCTIONS_YAML 45 ${CMAKE_CURRENT_BINARY_DIR}/merged.yaml 46 ) 47 message("Generated files ${gen_command_sources}") 48 49 # optimized_native_cpu_ops_lib: Register optimized op kernels into the runtime 50 gen_operators_lib( 51 LIB_NAME 52 "optimized_native_cpu_ops_lib" 53 KERNEL_LIBS 54 portable_kernels 55 optimized_kernels 56 DEPS 57 executorch 58 ) 59 60 install(TARGETS optimized_native_cpu_ops_lib DESTINATION lib) 61endif() 62