-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
72 lines (58 loc) · 2.02 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
cmake_minimum_required(VERSION 3.5)
project(blaze CXX)
include(cmake/CPM.cmake)
include(cmake/sanitizers.cmake)
CPMAddPackage(
NAME libcoro
VERSION 0.3
GITHUB_REPOSITORY "jbaldwin/libcoro"
GIT_TAG "v0.3"
OPTIONS "LIBCORO_BUILD_TESTS OFF" "LIBCORO_BUILD_EXAMPLES OFF"
)
CPMAddPackage(
NAME fmt
VERSION 8.1.1
GITHUB_REPOSITORY "fmtlib/fmt"
GIT_TAG "8.1.1"
)
message(STATUS "use c++20")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
option(USE_GPU_DEVICE "Use GPU device" OFF)
if(USE_GPU_DEVICE)
set(ONNXRUNTIME_DIR "/onnxruntime/onnxruntime-linux-x64-gpu-1.12.1")
add_compile_definitions(USE_GPU=1)
else()
set(ONNXRUNTIME_DIR "/onnxruntime/onnxruntime-linux-x64-1.12.1")
add_compile_definitions(USE_GPU=0)
endif()
message(STATUS "Using GPU: ${USE_GPU_DEVICE}")
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
add_sanitizer("AddressLeak")
endif()
find_package(Drogon CONFIG REQUIRED)
find_package(OpenCV REQUIRED)
add_executable(${PROJECT_NAME} main.cc controllers/)
target_include_directories(${PROJECT_NAME} PRIVATE "${ONNXRUNTIME_DIR}/include")
target_link_libraries(${PROJECT_NAME} PRIVATE Drogon::Drogon fmt::fmt ${OpenCV_LIBS} libcoro "${ONNXRUNTIME_DIR}/lib/libonnxruntime.so")
target_compile_options(${PROJECT_NAME} PRIVATE -std=c++20 -fcoroutines $<$<CONFIG:Release>:-march=native -mtune=native -flto>)
aux_source_directory(controllers CTL_SRC)
aux_source_directory(filters FILTER_SRC)
aux_source_directory(plugins PLUGIN_SRC)
aux_source_directory(models MODEL_SRC)
aux_source_directory(lib LIB_SRC)
drogon_create_views(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/views
${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(${PROJECT_NAME}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/models)
target_sources(${PROJECT_NAME}
PRIVATE
${CTL_SRC}
${FILTER_SRC}
${PLUGIN_SRC}
${MODEL_SRC}
${LIB_SRC})
# Test targets
add_subdirectory(test)