-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
91 lines (63 loc) · 2.47 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
# set cmake_install_prefix path
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
endif()
message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
# check if building type is not set
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build" FORCE)
endif()
# bsp
if(NOT BSP_MSP_DIR)
set(BSP_MSP_DIR ${CMAKE_SOURCE_DIR}/axpi_pro_bsp_sdk/msp/out)
endif()
message(STATUS "BSP_MSP_DIR = ${BSP_MSP_DIR}")
# set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/toolchains/aarch64-none-linux-gnu.toolchain.cmake)
cmake_minimum_required(VERSION 3.0)
project(SegmentAnything-AX650)
# 添加 FLAGS 检查代码是否有明显 bug
include(cmake/overlook.cmake)
add_compile_options(-std=c++17)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# link third-party library onnxruntime-win-x64-1.14.1 and opencv4
if(NOT ONNXRUNTIME_DIR)
set(ONNXRUNTIME_DIR ${CMAKE_SOURCE_DIR}/third_party/onnxruntime-aarch64-none-gnu-1.16.0)
endif()
message(STATUS "ONNXRUNTIME_DIR Path: ${ONNXRUNTIME_DIR}")
include_directories(${ONNXRUNTIME_DIR}/include)
link_directories("${ONNXRUNTIME_DIR}/lib")
set(ONNXRUNTIME_LIB onnxruntime)
if(NOT OpenCV_DIR)
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/third_party/libopencv-4.6-aarch64-none/lib/cmake/opencv4)
endif()
message(STATUS "OPENCV_DIR Path: ${OpenCV_DIR}")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${BSP_MSP_DIR}/include)
link_directories(${BSP_MSP_DIR}/lib)
option(BUILD_WITH_AX650 "build with ax650" OFF)
if(BUILD_WITH_AX650)
add_compile_definitions(BUILD_WITH_AX650)
endif()
message(STATUS "BUILD_WITH_AX650 : ${BUILD_WITH_AX650}")
add_library(sam STATIC
src/Runner/BaseRunner.cpp
src/Runner/ax_model_runner_ax650.cpp
)
add_executable(main src/main.cpp)
target_link_libraries(main sam)
target_link_libraries(main ${OpenCV_LIBS})
target_link_libraries(main gomp ${ONNXRUNTIME_LIB})
if(BUILD_WITH_AX650)
target_link_libraries(main ax_engine ax_interpreter ax_sys ax_ivps)
endif()
install(TARGETS main DESTINATION bin)
add_executable(main_inpaint src/main_inpaint.cpp)
target_link_libraries(main_inpaint sam)
target_link_libraries(main_inpaint ${OpenCV_LIBS})
target_link_libraries(main_inpaint gomp ${ONNXRUNTIME_LIB})
if(BUILD_WITH_AX650)
target_link_libraries(main_inpaint ax_engine ax_interpreter ax_sys ax_ivps)
endif()
install(TARGETS main_inpaint DESTINATION bin)