-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
91 lines (77 loc) · 2.73 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
cmake_minimum_required(VERSION 3.13)
# Project and compilation flags
project(main VERSION 0.1.0 LANGUAGES C CXX)
if (WIN32)
string(APPEND CMAKE_CXX_FLAGS " /W4")
else()
string(APPEND CMAKE_CXX_FLAGS " -D_GLIBCXX_USE_CXX11_ABI=0 -Wall -Wextra")
string(APPEND CMAKE_C_FLAGS " -Wall -Wextra")
endif()
set (CMAKE_CXX_STANDARD 20)
set(BUILD_SHARED_LIBS ON)
# basic conan config
message(STATUS ${CMAKE_BINARY_DIR})
message(STATUS ${CMAKE_SOURCE_DIR})
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
# add external cmake files
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_BINARY_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# find packages
find_package(cxxopts REQUIRED)
find_package(OpenCV REQUIRED)
# opencv variable logging
message(STATUS "OpenCV_FOUND: ${OpenCV_FOUND}")
message(STATUS "OpenCV_LIBS: ${OpenCV_LIBS}")
message(STATUS "OpenCV_INCLUDE_DIRS: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "OpenCV_VERSION: ${OpenCV_VERSION}")
# onnxruntime providers
option(onnxruntime_USE_CUDA "Build with CUDA support" OFF)
option(onnxruntime_USE_OPENVINO "Build with OpenVINO support" OFF)
option(onnxruntime_USE_NNAPI_BUILTIN "Build with builtin NNAPI lib for Android NNAPI support" OFF)
option(onnxruntime_USE_DNNL "Build with DNNL support" OFF)
option(onnxruntime_USE_NUPHAR "Build with Nuphar" OFF)
option(onnxruntime_USE_TENSORRT "Build with TensorRT support" OFF)
option(ONNXRUNTIME_ROOTDIR "onnxruntime root dir")
if(NOT ONNXRUNTIME_ROOTDIR)
message(FATAL_ERROR "please specify the installation path for ONNXRUNTIME_ROOTDIR to cmake")
endif()
# onnxruntime debug log
message(STATUS "OnnRuntime directory: ${ONNXRUNTIME_ROOTDIR}")
if(onnxruntime_USE_CUDA)
add_definitions(-DUSE_CUDA)
endif()
if(onnxruntime_USE_OPENVINO)
add_definitions(-DUSE_OPENVINO)
endif()
if(onnxruntime_USE_NNAPI_BUILTIN)
add_definitions(-DUSE_NNAPI)
endif()
if(onnxruntime_USE_DNNL)
add_definitions(-DUSE_DNNL)
endif()
if(onnxruntime_USE_NUPHAR)
add_definitions(-DUSE_NUPHAR)
endif()
if(onnxruntime_USE_TENSORRT)
add_definitions(-DUSE_TENSORRT)
endif()
if(onnxruntime_USE_DML)
message("Enabling DML")
add_definitions(-DUSE_DML)
endif()
# # project library bindings
include_directories("${ONNXRUNTIME_ROOTDIR}/include" "${ONNXRUNTIME_ROOTDIR}/include/onnxruntime/core/session" ${OpenCV_INCLUDE_DIRS} )
link_directories("${ONNXRUNTIME_ROOTDIR}/lib")
add_library(utils STATIC
src/FileSystem.h
src/FileSystem.cpp
src/vectorOperations.h
src/imageOperations.h
src/imageOperations.cpp
src/exceptions.h
src/OnnxInferenceRunner.h
src/OnnxInferenceRunner.cpp
)
target_link_libraries(utils PUBLIC ${OpenCV_LIBS})
add_executable(main src/main.cpp)
target_link_libraries(main PUBLIC utils onnxruntime cxxopts::cxxopts)