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