4
4
# except in compliance with the License. See the license file in the root
5
5
# directory of this source tree for more details.
6
6
7
- set (CMAKE_CXX_STANDARD 17)
8
-
9
7
cmake_minimum_required (VERSION 3.19)
10
8
project (openvino_runner_example)
11
9
10
+ set (CMAKE_CXX_STANDARD 17)
11
+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
12
+ set (CMAKE_CXX_EXTENSIONS OFF )
13
+
12
14
# Source root directory for executorch.
13
15
if (NOT EXECUTORCH_ROOT)
14
16
set (EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR} /../..)
@@ -26,31 +28,20 @@ if(NOT CMAKE_BUILD_TYPE)
26
28
endif ()
27
29
28
30
set (_common_compile_options -Wno-deprecated-declarations -fPIC)
29
-
30
- # Let files say "include <executorch/path/to/header.h>".
31
31
set (_common_include_directories ${EXECUTORCH_ROOT} /..)
32
32
33
- #
34
- # The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
35
- #
36
- set (EXECUTORCH_SRCS_FILE
37
- "${CMAKE_CURRENT_BINARY_DIR} /../../../build/executorch_srcs.cmake"
38
- )
33
+ set (EXECUTORCH_SRCS_FILE "${CMAKE_CURRENT_BINARY_DIR} /../../../build/executorch_srcs.cmake" )
39
34
extract_sources(${EXECUTORCH_SRCS_FILE} )
40
35
include (${EXECUTORCH_SRCS_FILE} )
41
36
42
- set (_openvino_executor_runner__srcs ${CMAKE_CURRENT_LIST_DIR} /../openvino/executor_runner/openvino_executor_runner.cpp)
43
-
44
- # preprocess executor runner src files
45
- list (PREPEND _openvino_executor_runner__srcs
46
- ${CMAKE_CURRENT_LIST_DIR} /../openvino/executor_runner/openvino_executor_runner.cpp
37
+ set (_openvino_executor_runner__srcs
38
+ ${CMAKE_CURRENT_LIST_DIR} /../openvino/executor_runner/openvino_executor_runner.cpp
47
39
)
48
40
49
41
find_package (executorch CONFIG REQUIRED)
50
- target_include_directories (executorch INTERFACE ${_common_include_directories} )
51
- target_compile_options (executorch INTERFACE ${_common_compile_options} )
42
+ include_directories (${EXECUTORCH_INCLUDE_DIRS} )
52
43
53
- # portable_ops_lib
44
+ # Portable Ops Library
54
45
gen_selected_ops(LIB_NAME "openvino_portable_ops_lib" INCLUDE_ALL_OPS "ON" )
55
46
generate_bindings_for_kernels(
56
47
LIB_NAME "openvino_portable_ops_lib" FUNCTIONS_YAML
@@ -59,43 +50,45 @@ generate_bindings_for_kernels(
59
50
gen_operators_lib(
60
51
LIB_NAME "openvino_portable_ops_lib" KERNEL_LIBS portable_kernels DEPS executorch
61
52
)
62
- target_compile_options (
63
- openvino_portable_ops_lib INTERFACE -DET_EVENT_TRACER_ENABLED
64
- )
65
- target_include_directories (
66
- openvino_portable_ops_lib PUBLIC ${_common_include_directories}
67
- )
53
+ target_compile_options (openvino_portable_ops_lib INTERFACE -DET_EVENT_TRACER_ENABLED)
54
+ target_include_directories (openvino_portable_ops_lib PUBLIC ${_common_include_directories} )
68
55
69
-
70
- # build executor runner
56
+ # Build Executor Runner
71
57
add_executable (openvino_executor_runner ${_openvino_executor_runner__srcs} )
72
58
target_include_directories (
73
- openvino_executor_runner PUBLIC ${_common_include_directories}
59
+ openvino_executor_runner PUBLIC ${_common_include_directories} ${EXECUTORCH_ROOT} /cmake-openvino-out/third-party/gflags/ include
74
60
)
75
61
76
- # Set the path to the library directory
77
- set (LIBRARY_DIR "${CMAKE_CURRENT_LIST_DIR} /../../cmake-openvino-out/lib/" )
78
-
79
- # List the libraries you want to link (without the 'lib' prefix and file extension)
80
- set (LIBRARIES_TO_LINK ${LIBRARY_DIR} /libopenvino_backend.so
81
- ${LIBRARY_DIR} /libexecutorch.a
82
- ${LIBRARY_DIR} /libexecutorch_core.a
83
- ${EXECUTORCH_ROOT} /third-party/gflags/build /lib/libgflags_nothreads.a
84
- ${LIBRARY_DIR} /libpthreadpool.a
85
- ${LIBRARY_DIR} /libextension_data_loader.a
86
- ${LIBRARY_DIR} /libextension_runner_util.a
87
- )
62
+ # Set Library Directory
63
+ set (LIBRARY_DIR "${CMAKE_CURRENT_LIST_DIR} /../../cmake-openvino-out/lib/;${CMAKE_CURRENT_LIST_DIR} /../../cmake-openvino-out/third-party/gflags" )
64
+ message (STATUS "Library directory path: ${LIBRARY_DIR} " )
88
65
89
- # Add the library directory to the link search path
90
- link_directories (${LIBRARY_DIR} )
66
+ # Locate OpenVINO Backend Library
67
+ find_library (OPENVINO_BACKEND_LIB NAMES openvino_backend PATHS ${LIBRARY_DIR} NO_DEFAULT_PATH)
68
+ if (NOT OPENVINO_BACKEND_LIB)
69
+ message (FATAL_ERROR "OpenVINO backend library not found in ${LIBRARY_DIR} " )
70
+ endif ()
91
71
92
- # Link all libraries at once
93
- target_link_libraries (openvino_executor_runner PRIVATE ${LIBRARIES_TO_LINK} openvino_portable_ops_lib)
72
+ # Locate OpenVINO Backend Library
73
+ find_library (GFLAGS_LIB NAMES gflags_nothreads PATHS ${LIBRARY_DIR} NO_DEFAULT_PATH)
74
+ if (NOT GFLAGS_LIB)
75
+ message (FATAL_ERROR "Gflags library not found in ${LIBRARY_DIR} " )
76
+ endif ()
94
77
95
- set_target_properties (
96
- openvino_executor_runner PROPERTIES LINK_FLAGS "-Wl,-rpath='$ORIGIN'"
78
+ # Link Libraries
79
+ target_link_libraries (openvino_executor_runner PRIVATE
80
+ ${OPENVINO_BACKEND_LIB}
81
+ ${GFLAGS_LIB}
82
+ executorch
83
+ executorch_core
84
+ openvino_portable_ops_lib
85
+ extension_data_loader
86
+ extension_runner_util
87
+ pthreadpool
97
88
)
98
89
90
+ # Ensure Proper RPATH Handling
91
+ set_target_properties (openvino_executor_runner PROPERTIES INSTALL_RPATH "$ORIGIN" )
99
92
100
93
get_filename_component (
101
94
EXECUTORCH_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR} /../.." ABSOLUTE
0 commit comments