-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
129 lines (117 loc) · 4.37 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
# Copyright (C) 2020 Intel Corporation
#
cmake_minimum_required(VERSION 3.16)
#set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDERR)
function(load_config path)
file(STRINGS "${path}" list)
list(FILTER list EXCLUDE REGEX "^ *#")
foreach(env IN LISTS list)
string(REGEX REPLACE "^ *([A-Za-z_][A-Za-z0-9_]*) *= *[Yy].*$" "\\1" var "${env}")
if(NOT "${var}" STREQUAL "${env}")
set(ENV{${var}} "y")
endif()
endforeach()
endfunction()
if(EXISTS "${BUILD_CONFIG}")
set(BUILD_CONFIG "" CACHE FILEPATH "configuration file")
load_config("${BUILD_CONFIG}")
elseif("${BUILD_CONFIG}" STREQUAL "FULL")
set(ENV{CONFIG_OPENVINO} y)
set(ENV{CONFIG_PYTORCH} y)
set(ENV{CONFIG_ONNX} y)
set(ENV{CONFIG_TENSORFLOW} y)
set(ENV{CONFIG_PADDLE} y)
set(ENV{CONFIG_RESTFUL_SERVICE} y)
set(ENV{CONFIG_RESTFUL_CAPABILITY} y)
set(ENV{CONFIG_RESTFUL_SAMPLE} y)
set(ENV{CONFIG_GRPC_SERVICE} y)
set(ENV{CONFIG_GRPC_SAMPLE} y)
else()
message(FATAL_ERROR "config file not found")
endif()
# Global compiler/linker flags
add_compile_options(-Wall -fstack-protector-all) # -fvisibility=hidden)
add_compile_definitions(_FORTIFY_SOURCE=2)
add_link_options(LINKER:-z,relro)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,now")
set(CMAKE_INSTALL_SO_NO_EXE NO)
project(CCAI)
# Setup installation locations
include(GNUInstallDirs)
string(FIND "${CMAKE_INSTALL_LIBDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" result)
if(${result} EQUAL -1)
string(APPEND CMAKE_INSTALL_LIBDIR "/${CMAKE_LIBRARY_ARCHITECTURE}")
endif()
string(FIND "${CMAKE_INSTALL_LIBDIR}" "lib/" result)
if(${result} EQUAL 0)
string(FIND "${CMAKE_INSTALL_PREFIX}" "/usr" result)
if(NOT ${result} EQUAL 0)
string(PREPEND CMAKE_INSTALL_BINDIR "usr/")
string(PREPEND CMAKE_INSTALL_INCLUDEDIR "usr/")
string(PREPEND CMAKE_INSTALL_LIBDIR "usr/")
string(PREPEND CMAKE_INSTALL_SBINDIR "usr/")
endif()
endif()
# Find OpenVINO at default location
function(find_openvino)
set(openvino_dir "/opt/intel/openvino_2022")
if(EXISTS "${openvino_dir}")
set(iedir "${openvino_dir}/runtime/cmake")
set(cvdir "${openvino_dir}/extras/opencv/cmake")
else()
set(openvino_dir "/opt/intel/openvino_2021")
if(EXISTS "${openvino_dir}")
set(iedir "${openvino_dir}/deployment_tools/inference_engine/share")
set(cvdir "${openvino_dir}/opencv/cmake")
else()
return()
endif()
endif()
if(EXISTS "${iedir}/InferenceEngineConfig.cmake")
get_filename_component(iedir "${iedir}" REALPATH)
set(InferenceEngine_DIR "${iedir}" PARENT_SCOPE)
endif()
if(EXISTS "${cvdir}/OpenCVConfig.cmake")
get_filename_component(cvdir "${cvdir}" REALPATH)
set(OpenCV_DIR "${cvdir}" PARENT_SCOPE)
endif()
endfunction()
# Common dependencies
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
if(NOT DEFINED ENV{InferenceEngine_DIR})
find_openvino()
endif()
find_package(OpenCV REQUIRED core imgproc imgcodecs)
#find_package(PkgConfig REQUIRED)
#pkg_check_modules(JsonC REQUIRED IMPORTED_TARGET json-c)
function(install_get_abspath var path)
if(NOT IS_ABSOLUTE "${path}")
string(PREPEND path "${CMAKE_INSTALL_PREFIX}/")
if(NOT IS_ABSOLUTE "${path}")
string(PREPEND path "${CMAKE_BINARY_DIR}/")
endif()
endif()
set(${var} "${path}" PARENT_SCOPE)
endfunction()
function(install_link origin target)
string(REGEX REPLACE "/+$" "" dir "${target}")
if(dir STREQUAL target)
get_filename_component(dir "${target}" DIRECTORY)
else()
get_filename_component(name "${origin}" NAME)
string(APPEND target "${name}")
endif()
install_get_abspath(target ${target})
list(JOIN ARGN " " args)
install(DIRECTORY DESTINATION "${dir}")
install(CODE "file(CREATE_LINK \"${origin}\" \"${target}\" ${args})")
install(CODE "message(\"-- Make-link: ${target} -> ${origin}\")")
endfunction()
add_subdirectory(log)
add_subdirectory(inference-runtime)
add_subdirectory(video-streamer)
add_subdirectory(smart-photo)
add_subdirectory(api-gateway/fcgi)
add_subdirectory(api-gateway/grpc)
add_subdirectory(health-monitor/health-monitor-agent)
install(PROGRAMS "service_runtime_binary/lfs/rootfs/start.sh" DESTINATION ${CMAKE_INSTALL_PREFIX})