-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
197 lines (182 loc) · 6.61 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#
# Copyright (C) 2022 Xilinx, Inc.
# Copyright (C) 2023 – 2024 Advanced Micro Devices, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
cmake_minimum_required(VERSION 3.12)
project(
vart
VERSION 3.5.0
LANGUAGES C CXX)
link_directories("$ENV{CONDA_PREFIX}/lib")
include(${PROJECT_SOURCE_DIR}/cmake/VitisCommon.cmake)
option(ENABLE_CPU_RUNNER "enable cpu runner or not" OFF)
option(ENABLE_SIM_RUNNER "enable sim runner or not" OFF)
option(ENABLE_DPU_RUNNER "enable dpu runner or not" OFF)
option(ENABLE_XRNN_RUNNER "enable xrnn runner or not" OFF)
option(BUILD_PYTHON "build python library" OFF)
option(BUILD_TEST "build test" OFF)
option(LIBGLOG_RESTRICT "find libglog restrict in install prefix" OFF)
if (LIBGLOG_RESTRICT)
message(STATUS "Find glog in restrict mode")
find_package(glog PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH)
else ()
message(STATUS "Find glog in public mode")
find_package(glog QUIET)
endif (LIBGLOG_RESTRICT)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")
find_package(glog QUIET)
if(NOT glog_FOUND)
message(STATUS "cannot find glogConfig.cmake fallback to pkg-config")
find_package(PkgConfig)
pkg_search_module(PKG_GLOG REQUIRED IMPORTED_TARGET GLOBAL libglog)
add_library(glog::glog ALIAS PkgConfig::PKG_GLOG)
endif(NOT glog_FOUND)
find_package(Protobuf REQUIRED)
if(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
find_package(unilog REQUIRED)
find_package(xir REQUIRED)
find_package(target-factory REQUIRED)
endif()
find_package(Threads REQUIRED)
find_package(XRT HINTS /opt/xilinx/xrt/share/cmake/XRT)
if(XRT_FOUND)
if(TARGET XRT::xrt_coreutil)
# it brreaks all other runners if XRT obsolete this target.
# bugfix for XRT.cmake
set_target_properties(
XRT::xrt_coreutil PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
${XRT_INCLUDE_DIRS})
endif()
else(XRT_FOUND)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/my_find_xrt.cmake)
endif(XRT_FOUND)
if(${XRT_FOUND})
if(IS_EDGE)
set(XRT_EDGE_FOUND true)
set(XRT_CLOUD_FOUND false)
else()
set(XRT_EDGE_FOUND false)
set(XRT_CLOUD_FOUND true)
endif()
else(${XRT_FOUND})
set(XRT_EDGE_FOUND false)
set(XRT_CLOUD_FOUND false)
endif(${XRT_FOUND})
find_package(hiredis QUIET)
set(PACKAGE_COMPONENTS util runner trace dummy-runner)
if(NOT MSVC)
list(APPEND PACKAGE_COMPONENTS async-runner)
endif(NOT MSVC)
list(APPEND PACKAGE_COMPONENTS mem-manager)
if(ENABLE_DPU_RUNNER)
# append xrt-device-handle anyway, even if xrt is not found, because softmax
# controller is part if and vitis-ai-library needs such components.
list(APPEND PACKAGE_COMPONENTS xrt-device-handle)
list(APPEND PACKAGE_COMPONENTS buffer-object dpu-controller dpu-runner)
if(IS_EDGE)
list(APPEND PACKAGE_COMPONENTS softmax-runner softmax-runner-cpu)
endif(IS_EDGE)
endif()
if(ENABLE_SIM_RUNNER)
list(APPEND PACKAGE_COMPONENTS sim-runner)
endif()
if(ENABLE_CPU_RUNNER)
list(APPEND PACKAGE_COMPONENTS cpu-runner)
endif()
if(ENABLE_XRNN_RUNNER)
list(APPEND PACKAGE_COMPONENTS xrt-device-handle)
list(APPEND PACKAGE_COMPONENTS buffer-object xrnn-runner)
endif()
list(REMOVE_DUPLICATES PACKAGE_COMPONENTS)
foreach(COMPONENT ${PACKAGE_COMPONENTS})
add_subdirectory(${COMPONENT})
endforeach()
file(RELATIVE_PATH REL_INCLUDE_DIR
${CMAKE_INSTALL_PREFIX}/share/cmake/${PROJECT_NAME}
${CMAKE_INSTALL_PREFIX}/include)
set(CONF_INCLUDE_DIRS "\${${PROJECT_NAME}_CMAKE_DIR}/${REL_INCLUDE_DIR}")
configure_file(cmake/config.cmake.in
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake" @ONLY)
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
if(CMAKE_SOURCE_DIR STREQUAL vart_SOURCE_DIR)
install(
FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
COMPONENT base
DESTINATION share/cmake/${PROJECT_NAME})
endif()
set(CPACK_PACKAGE_NAME "libvart")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Vitis Ai RuntTime")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/Copyright.txt")
set(CPACK_PACKAGE_VENDOR "Humanity")
set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
set(CPACK_DEBIAN_ARCHIVE_TYPE "gnutar")
set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_DEPENDS
"libxir (>=1.2.0), libunilog (>=1.2.0), libtarget-factory (>=1.2.0)")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
if(DEFINED ENV{BUILD_NUMBER})
set(CPACK_DEBIAN_PACKAGE_RELEASE "r$ENV{BUILD_NUMBER}")
endif()
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
else()
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
endif()
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_RPM_PACKAGE_LICENSE "Apache")
set(CPACK_RPM_PACKAGE_GROUP "Development/Tools")
set(CPACK_RPM_COMPRESSION_TYPE "xz")
set(CPACK_RPM_PACKAGE_REQUIRES
"libxir >= 1.2.0, libunilog >= 1.2.0, libtarget-factory >= 1.2.0")
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
if(DEFINED ENV{BUILD_NUMBER})
set(CPACK_RPM_PACKAGE_RELEASE "r$ENV{BUILD_NUMBER}")
endif()
set(CPACK_RPM_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "cortexa72-cortexa53")
set(CPACK_RPM_PACKAGE_ARCHITECTURE "aarch64")
endif()
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
include(CPack)
cpack_add_component_group(all)
cpack_add_component(base GROUP all)
cpack_add_component(
cpu
GROUP all
DEPENDS base)
cpack_add_component(
dpu
GROUP all
DEPENDS base)
cpack_add_component(
sim
GROUP all
DEPENDS base)