forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
140 lines (108 loc) · 4.36 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
# Copyright (C) 2018-2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
if (NOT ENABLE_INTEL_GNA)
return()
endif()
set(TARGET_NAME "openvino_intel_gna_plugin")
if (ENABLE_INTEL_GNA_DEBUG)
add_compile_definitions(GNA_DEBUG)
endif()
if(CMAKE_COMPILER_IS_GNUCC)
ie_add_compiler_flags(-Wno-all)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# C4267, 4244 issues from mkl-dnn headers conversion from 'XXX' to 'YYY', possible loss of data
ie_add_compiler_flags(/wd4267)
ie_add_compiler_flags(/wd4244)
# '<': signed/unsigned mismatch
ie_add_compiler_flags(/wd4018)
ie_add_compiler_flags(/wd4099)
ie_add_compiler_flags(/wd4200)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# C4661: no suitable definition provided for explicit template instantiation request
ie_add_compiler_flags(/wd4661)
# C4297: function assumed not to throw an exception but does
ie_add_compiler_flags(/wd4297)
endif()
file(GLOB_RECURSE SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp)
addVersionDefines(src/gna_plugin_entry_points.cpp CI_BUILD_NUMBER)
find_package(libGNA REQUIRED
PATHS "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
NO_DEFAULT_PATH)
#
# Shared plugin library
#
ie_add_plugin(NAME ${TARGET_NAME}
DEVICE_NAME "GNA"
SOURCES ${SOURCES} ${HEADERS})
# Enable support of CC for the plugin
ie_mark_target_as_cc(${TARGET_NAME})
target_link_libraries(${TARGET_NAME} PRIVATE inference_engine_legacy
Threads::Threads libGNA)
target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_compile_definitions(${TARGET_NAME}
PRIVATE
_NO_MKL_
)
ie_add_api_validator_post_build_step(TARGET ${TARGET_NAME})
#
# Static version for tests
#
add_library(${TARGET_NAME}_test_static STATIC EXCLUDE_FROM_ALL ${SOURCES} ${HEADERS})
target_compile_definitions(${TARGET_NAME}_test_static
PRIVATE
_NO_MKL_
IMPLEMENT_INFERENCE_ENGINE_PLUGIN
PUBLIC
INTEGER_LOW_P
USE_STATIC_IE)
target_link_libraries(${TARGET_NAME}_test_static PUBLIC inference_engine_s inference_engine_transformations libGNA::API)
target_include_directories(${TARGET_NAME}_test_static
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
$<TARGET_PROPERTY:inference_engine_legacy,INTERFACE_INCLUDE_DIRECTORIES>
PRIVATE
$<TARGET_PROPERTY:openvino::conditional_compilation,INTERFACE_INCLUDE_DIRECTORIES>)
set_target_properties(${TARGET_NAME}_test_static PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}_test_static)
set_target_properties(${TARGET_NAME} ${TARGET_NAME}_test_static
PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})
# install
file(GLOB_RECURSE gna_libraries "${libGNA_LIBRARIES_BASE_PATH}/*${CMAKE_SHARED_LIBRARY_SUFFIX}*")
set(gna_library_installed OFF)
foreach(gna_lib IN LISTS gna_libraries)
# install only versioned files like libgna.so.N or libgna.so.N.M
# and don't install global symlink libgna.so. Exceptions:
# 1. On Windows we don't have libraries versioning and need to install all .dlls
# 2. For case of static libraries we also need to install .so since it's required for linkage with final application
if(gna_lib MATCHES "^.*\.${CMAKE_SHARED_LIBRARY_SUFFIX}(\.[0-9]+)+$" OR
WIN32 OR NOT BUILD_SHARED_LIBS)
install(FILES ${gna_lib}
DESTINATION ${OV_CPACK_RUNTIMEDIR}
COMPONENT gna)
set(gna_library_installed ON)
endif()
endforeach()
if(NOT gna_library_installed)
message(FATAL_ERROR "Failed to install GNA library (available libraries: ${gna_libraries})")
endif()
# additional install rules for case of static libraries
if(NOT BUILD_SHARED_LIBS)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/libGNAConfig.cmake ${CMAKE_BINARY_DIR} COPYONLY)
install(FILES "${CMAKE_BINARY_DIR}/libGNAConfig.cmake"
DESTINATION ${OV_CPACK_IE_CMAKEDIR}
COMPONENT gna)
# install .lib file on Windows
if(WIN32)
file(GLOB_RECURSE gna_libraries "${libGNA_LIBRARIES_BASE_PATH}/*${CMAKE_STATIC_LIBRARY_SUFFIX}")
install(FILES ${gna_libraries}
DESTINATION ${OV_CPACK_LIBRARYDIR}
COMPONENT gna)
endif()
endif()
add_subdirectory(tests)