-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
126 lines (99 loc) · 3.52 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
cmake_minimum_required(VERSION 3.15)
project(cpp-server)
if(DEFINED ENV{CXX_VERSION})
set(CMAKE_CXX_STANDARD $ENV{CXX_VERSION}) # set to 14 or 17 when available
else()
set(CMAKE_CXX_STANDARD 14)
endif()
option(ENABLE_TRITON "Enable Triton Engine" ON)
option(ENABLE_ONNXRT "Enable ONNXRT Engine" OFF)
option(RUN_TESTS "Wether to run tests" OFF)
if(RUN_TESTS)
message("Building with lcov Code Coverage Tools")
FIND_PROGRAM(GCOV_PATH gcov)
FIND_PROGRAM(LCOV_PATH lcov)
FIND_PROGRAM(GENHTML_PATH genhtml)
# Warning/Error messages
if(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug"))
message(WARNING "Code coverage results with an optimized (non-Debug) build may be misleading")
endif()
if(NOT LCOV_PATH)
message(FATAL_ERROR "lcov not found! Aborting...")
endif()
if(NOT GENHTML_PATH)
message(FATAL_ERROR "genhtml not found! Aborting...")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
endif()
find_package(Boost COMPONENTS context fiber date_time url REQUIRED)
find_package(RapidJSON REQUIRED)
find_package(OpenCV 4 REQUIRED)
if(ENABLE_TRITON)
find_package(Protobuf REQUIRED)
find_package(TritonCommon REQUIRED PATHS /usr/local/lib/cmake/TritonCommon)
find_package(TritonClient REQUIRED PATHS /usr/local/lib/cmake/TritonClient)
endif()
include_directories(
include
)
add_library(common_utils
src/utils/error.cpp
src/utils/base64.cpp
)
add_library(image_processor
src/image_processor.cpp
)
if(ENABLE_TRITON)
add_library(triton_inference_engine
src/triton_engine.cpp
src/triton_helper.cpp
)
endif()
if(ENABLE_ONNXRT)
add_library(onnxrt_inference_engine
src/onnxrt_engine.cpp
src/onnxrt_helper.cpp
)
endif()
target_link_libraries(image_processor common_utils)
if(RapidJSON_FOUND)
target_include_directories(image_processor PUBLIC ${RapidJSON_INCLUDE_DIRS})
endif()
if(OpenCV_FOUND)
target_include_directories(image_processor PUBLIC ${OpenCV_INCLUDE_DIR})
target_link_libraries(image_processor ${OpenCV_LIBS})
endif()
if(ENABLE_TRITON)
target_link_libraries(triton_inference_engine
${OpenCV_LIBS}
common_utils
)
if(OpenCV_FOUND)
target_include_directories(triton_inference_engine PUBLIC ${OpenCV_INCLUDE_DIR})
target_link_libraries(triton_inference_engine ${OpenCV_LIBS})
endif()
if(Protobuf_FOUND)
target_include_directories(triton_inference_engine PUBLIC ${Protobuf_INCLUDE_DIRS})
target_link_libraries(triton_inference_engine ${Protobuf_LIBRARIES})
endif()
if(TritonClient_FOUND)
target_include_directories(triton_inference_engine PUBLIC ${TritonClient_INCLUDE_DIR} ${TritonCommon_INCLUDE_DIR})
target_link_libraries(triton_inference_engine TritonClient::httpclient TritonClient::grpcclient)
endif()
if(TritonCommon_FOUND)
target_include_directories(triton_inference_engine PUBLIC ${TritonCommon_INCLUDE_DIR})
target_link_libraries(triton_inference_engine TritonCommon::triton-common-model-config TritonCommon::triton-common-json)
endif()
endif()
if(ENABLE_ONNXRT)
target_include_directories(onnxrt_inference_engine PUBLIC /usr/local/include/onnxruntime)
target_link_libraries(onnxrt_inference_engine
/usr/local/lib/libonnxruntime.so
common_utils)
endif()
add_subdirectory(examples)
if(RUN_TESTS)
enable_testing()
add_subdirectory(tests)
endif()