|
| 1 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | +cmake_minimum_required(VERSION 3.31) |
| 5 | + |
| 6 | +project(BasicPluginEp) |
| 7 | + |
| 8 | +set(CMAKE_CXX_STANDARD 20) |
| 9 | + |
| 10 | +set(plugin_ep_common_dir ${CMAKE_SOURCE_DIR}/../common) |
| 11 | + |
| 12 | +include(${plugin_ep_common_dir}/cmake/onnxruntime_library_utils.cmake) |
| 13 | + |
| 14 | +# Set ORT_HOME (e.g., with cmake -DORT_HOME=/path/to/ort_home) to specify the directory with the ONNX Runtime header |
| 15 | +# and library files to use. |
| 16 | +# This is optional. If unspecified, the ONNX Runtime files will be downloaded. |
| 17 | + |
| 18 | +set_onnxruntime_paths( |
| 19 | + ORT_HOME ${ORT_HOME} |
| 20 | + DEFAULT_ORT_VERSION "1.23.2" |
| 21 | + ORT_INCLUDE_DIR_VAR ORT_INCLUDE_DIR |
| 22 | + ORT_LIBRARY_DIR_VAR ORT_LIBRARY_DIR) |
| 23 | + |
| 24 | +message(STATUS "ORT_LIBRARY_DIR: ${ORT_LIBRARY_DIR}") |
| 25 | +message(STATUS "ORT_INCLUDE_DIR: ${ORT_INCLUDE_DIR}") |
| 26 | + |
| 27 | +# |
| 28 | +# basic_plugin_ep |
| 29 | +# |
| 30 | +block() |
| 31 | + |
| 32 | +add_library(basic_plugin_ep MODULE) |
| 33 | + |
| 34 | +target_sources(basic_plugin_ep PRIVATE |
| 35 | + ${CMAKE_SOURCE_DIR}/src/ep_factory.cc |
| 36 | + ${CMAKE_SOURCE_DIR}/src/ep_factory.h |
| 37 | + ${CMAKE_SOURCE_DIR}/src/ep_lib_entry.cc |
| 38 | + ${CMAKE_SOURCE_DIR}/src/ep.cc |
| 39 | + ${CMAKE_SOURCE_DIR}/src/ep.h |
| 40 | + ${plugin_ep_common_dir}/src/plugin_ep_utils.h |
| 41 | +) |
| 42 | + |
| 43 | +target_include_directories(basic_plugin_ep PRIVATE |
| 44 | + ${ORT_INCLUDE_DIR} |
| 45 | + ${plugin_ep_common_dir}/src |
| 46 | +) |
| 47 | + |
| 48 | +target_link_directories(basic_plugin_ep PRIVATE ${ORT_LIBRARY_DIR}) |
| 49 | +target_link_libraries(basic_plugin_ep PRIVATE onnxruntime) |
| 50 | + |
| 51 | +set(basic_plugin_ep_link_options) |
| 52 | +if(MSVC) |
| 53 | + list(APPEND basic_plugin_ep_link_options |
| 54 | + "-DEF:${CMAKE_SOURCE_DIR}/src/ep_lib.def") |
| 55 | +else() |
| 56 | + if(UNIX) |
| 57 | + if(APPLE) |
| 58 | + list(APPEND basic_plugin_ep_link_options |
| 59 | + "LINKER:-dead_strip") |
| 60 | + else() |
| 61 | + list(APPEND basic_plugin_ep_link_options |
| 62 | + "LINKER:--version-script=${CMAKE_SOURCE_DIR}/src/ep_lib.lds" |
| 63 | + "LINKER:--no-undefined" |
| 64 | + "LINKER:--gc-sections" |
| 65 | + "-z" "noexecstack") |
| 66 | + endif() |
| 67 | + endif() |
| 68 | +endif() |
| 69 | + |
| 70 | +target_link_options(basic_plugin_ep PRIVATE ${basic_plugin_ep_link_options}) |
| 71 | + |
| 72 | +endblock() |
0 commit comments