|
| 1 | +# Copyright (c) Intel Corporation |
| 2 | +# |
| 3 | +# Licensed under the BSD License (the "License"); you may not use this file |
| 4 | +# except in compliance with the License. See the license file found in the |
| 5 | +# LICENSE file in the root directory of this source tree. |
| 6 | + |
| 7 | +# Set minimum required CMake version |
| 8 | +cmake_minimum_required(VERSION 3.19) |
| 9 | + |
| 10 | +# Set project name |
| 11 | +project(openvino_backend_project) |
| 12 | + |
| 13 | +# Set C++ standard |
| 14 | +set(CMAKE_CXX_STANDARD 17) |
| 15 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 16 | + |
| 17 | +# Ensure compile_commands.json is generated |
| 18 | +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 19 | + |
| 20 | +# Set up EXECUTORCH_ROOT if not already set |
| 21 | +if(NOT EXECUTORCH_ROOT) |
| 22 | + set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) |
| 23 | +endif() |
| 24 | + |
| 25 | +# Define common include directories |
| 26 | +set(COMMON_INCLUDE_DIRS ${EXECUTORCH_ROOT}/..) |
| 27 | + |
| 28 | +# Include utility CMake scripts from ExecuteTorch |
| 29 | +include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) |
| 30 | + |
| 31 | +# Find OpenVINO libraries |
| 32 | +find_package(OpenVINO REQUIRED) |
| 33 | + |
| 34 | +# Define OpenVINO backend as a static library |
| 35 | +add_library(openvino_backend STATIC .) |
| 36 | + |
| 37 | +# Enable exceptions and RTTI for OpenVINO backend |
| 38 | +target_compile_options(openvino_backend PRIVATE -frtti -fexceptions) |
| 39 | + |
| 40 | +# Include Executorch directories |
| 41 | +target_include_directories(openvino_backend PUBLIC ${COMMON_INCLUDE_DIRS}) |
| 42 | + |
| 43 | +# Link OpenVINO and ExecuteTorch core libraries |
| 44 | +target_link_libraries(openvino_backend PRIVATE openvino::runtime executorch_core) |
| 45 | + |
| 46 | +# Add source files for OpenVINO backend |
| 47 | +target_sources(openvino_backend PRIVATE ${CMAKE_CURRENT_LIST_DIR}/runtime/OpenvinoBackend.cpp) |
| 48 | + |
| 49 | +target_link_options_shared_lib(openvino_backend) |
| 50 | + |
| 51 | +if(EXECUTORCH_BUILD_OPENVINO_EXECUTOR_RUNNER) |
| 52 | + # Build executor runner binary for openvino backend |
| 53 | + list(APPEND openvino_executor_runner_libs openvino_backend executorch) |
| 54 | + |
| 55 | + set(_openvino_executor_runner__srcs |
| 56 | + ${EXECUTORCH_ROOT}/examples/portable/executor_runner/executor_runner.cpp |
| 57 | + ${EXECUTORCH_ROOT}/extension/data_loader/file_data_loader.cpp |
| 58 | + ${EXECUTORCH_ROOT}/extension/evalue_util/print_evalue.cpp |
| 59 | + ${EXECUTORCH_ROOT}/extension/runner_util/inputs.cpp |
| 60 | + ${EXECUTORCH_ROOT}/extension/runner_util/inputs_portable.cpp |
| 61 | + ) |
| 62 | + add_executable(openvino_executor_runner ${_openvino_executor_runner__srcs}) |
| 63 | + |
| 64 | + list(APPEND openvino_executor_runner_libs) |
| 65 | + |
| 66 | + target_link_libraries( |
| 67 | + openvino_executor_runner gflags portable_ops_lib ${openvino_executor_runner_libs} |
| 68 | + ) |
| 69 | + target_compile_options(openvino_executor_runner PUBLIC ${_common_compile_options}) |
| 70 | +endif() |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +# Install OpenVINO backend library to the lib directory |
| 75 | +install(TARGETS openvino_backend DESTINATION lib) |
0 commit comments