forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
156 lines (118 loc) · 5.44 KB
/
CMakeLists.txt
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
set (TARGET_NAME "openvino_runtime")
file (GLOB LIBRARY_SRC
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/dev/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/dev/preprocessing/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/dev/threading/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/threading/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/cpp_interfaces/interface/*.cpp
)
file (GLOB LIBRARY_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp
)
if(WIN32)
file (GLOB LIBRARY_SRC
${LIBRARY_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/src/os/win/*.cpp)
file (GLOB LIBRARY_HEADERS
${LIBRARY_HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/src/os/win/*.hpp)
elseif(APPLE)
file (GLOB LIBRARY_SRC
${LIBRARY_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/src/os/mac/*.cpp)
file (GLOB LIBRARY_HEADERS
${LIBRARY_HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/src/os/mac/*.hpp)
elseif(NOT EMSCRIPTEN)
file (GLOB LIBRARY_SRC
${LIBRARY_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/src/os/lin/*.cpp)
file (GLOB LIBRARY_HEADERS
${LIBRARY_HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/src/os/lin/*.hpp)
endif()
set (PUBLIC_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
file (GLOB_RECURSE PUBLIC_HEADERS
${PUBLIC_HEADERS_DIR}/*.hpp
${PUBLIC_HEADERS_DIR}/*.h
)
# Create named folders for the sources within the .vcproj
# Empty name lists them directly under the .vcproj
source_group("src" FILES ${LIBRARY_SRC})
source_group("include" FILES ${LIBRARY_HEADERS} ${PUBLIC_HEADERS})
# Create object library
add_library(${TARGET_NAME}_obj OBJECT
${LIBRARY_SRC}
${LIBRARY_HEADERS}
${PUBLIC_HEADERS})
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(${TARGET_NAME}_obj PUBLIC OPENVINO_STATIC_LIBRARY)
endif()
ov_build_target_faster(${TARGET_NAME}_obj
UNITY PCH PRIVATE "src/precomp.hpp"
)
target_compile_definitions(${TARGET_NAME}_obj PRIVATE
IMPLEMENT_OPENVINO_RUNTIME_API
$<$<TARGET_EXISTS:openvino_proxy_plugin_obj>:PROXY_PLUGIN_ENABLED>)
target_include_directories(${TARGET_NAME}_obj SYSTEM PRIVATE
$<TARGET_PROPERTY:openvino::pugixml,INTERFACE_INCLUDE_DIRECTORIES>
$<$<TARGET_EXISTS:xbyak::xbyak>:$<TARGET_PROPERTY:xbyak::xbyak,INTERFACE_INCLUDE_DIRECTORIES>>)
target_include_directories(${TARGET_NAME}_obj PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src"
$<TARGET_PROPERTY:openvino::runtime::dev,INTERFACE_INCLUDE_DIRECTORIES>
$<$<TARGET_EXISTS:openvino_proxy_plugin_obj>:$<TARGET_PROPERTY:openvino_proxy_plugin_obj,INTERFACE_INCLUDE_DIRECTORIES>>
# for ov_plugins.hpp
$<IF:$<AND:$<BOOL:${OV_GENERATOR_MULTI_CONFIG}>,$<VERSION_GREATER_EQUAL:${CMAKE_VERSION},3.20>>,${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>,${CMAKE_CURRENT_BINARY_DIR}>)
target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::itt openvino::util openvino::core::dev)
ov_mark_target_as_cc(${TARGET_NAME}_obj)
# OpenVINO Runtime is public API => need to mark this library as important for ABI free
ov_abi_free_target(${TARGET_NAME}_obj)
ov_set_threading_interface_for(${TARGET_NAME}_obj)
if (TBBBIND_2_5_FOUND)
target_link_libraries(${TARGET_NAME}_obj PRIVATE ${TBBBIND_2_5_IMPORTED_TARGETS})
endif()
# Create library file from object library
add_library(${TARGET_NAME} INTERFACE)
target_link_libraries(${TARGET_NAME} INTERFACE openvino::runtime)
target_include_directories(${TARGET_NAME} INTERFACE $<BUILD_INTERFACE:${PUBLIC_HEADERS_DIR}>)
ov_add_clang_format_target(${TARGET_NAME}_clang FOR_SOURCES ${LIBRARY_SRC} ${LIBRARY_HEADERS} ${PUBLIC_HEADERS})
ov_ncc_naming_style(FOR_TARGET ${TARGET_NAME}_obj
SOURCE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include/openvino"
ADDITIONAL_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:openvino::core::dev,INTERFACE_INCLUDE_DIRECTORIES>)
# Static library used for unit tests which are always built
add_library(${TARGET_NAME}_s STATIC
$<$<TARGET_EXISTS:openvino_proxy_plugin_obj>:$<TARGET_OBJECTS:openvino_proxy_plugin_obj>>
$<TARGET_OBJECTS:${TARGET_NAME}_obj>)
ov_set_threading_interface_for(${TARGET_NAME}_s)
if (TBBBIND_2_5_FOUND)
target_link_libraries(${TARGET_NAME}_s PRIVATE ${TBBBIND_2_5_IMPORTED_TARGETS})
endif()
target_include_directories(${TARGET_NAME}_s PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>)
if(WIN32)
set_target_properties(${TARGET_NAME}_s PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}_s)
endif()
target_link_libraries(${TARGET_NAME}_s PRIVATE openvino::itt ${CMAKE_DL_LIBS}
openvino::runtime::dev openvino::pugixml)
target_compile_definitions(${TARGET_NAME}_s PUBLIC USE_STATIC_IE)
set_target_properties(${TARGET_NAME}_s PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
# LTO
set_target_properties(${TARGET_NAME}_obj
PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
# Export for developer package
ov_developer_package_export_targets(TARGET ${TARGET_NAME}_s)
# Install static libraries for case BUILD_SHARED_LIBS=OFF
install(DIRECTORY "${PUBLIC_HEADERS_DIR}/"
DESTINATION ${OV_CPACK_INCLUDEDIR}
COMPONENT ${OV_CPACK_COMP_CORE_DEV}
${OV_CPACK_COMP_CORE_DEV_EXCLUDE_ALL})
if(ENABLE_TESTS)
add_subdirectory(tests)
endif()