-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
102 lines (82 loc) · 3.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
cmake_minimum_required(VERSION 3.15)
project(dartcv_library VERSION 1.0.0 LANGUAGES C CXX)
set(LIBRARY_NAME "dartcv")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
# must include
# option(DARTCV_WITH_CORE "Include core, imgcodecs models of opencv" ON)
option(DARTCV_WITH_CALIB3D "Include calib3d module of opencv" ON)
option(DARTCV_WITH_CONTRIB "Include contrib module of opencv" ON)
option(DARTCV_WITH_DNN "Include dnn module of opencv" ON)
option(DARTCV_WITH_FEATURES2D "Include features2d module of opencv" ON)
option(DARTCV_WITH_HIGHGUI "Include highgui module of opencv" OFF)
option(DARTCV_WITH_IMGPROC "Include imgproc module of opencv" ON)
option(DARTCV_WITH_OBJDETECT "Include objdetect module of opencv" ON)
option(DARTCV_WITH_PHOTO "Include photo module of opencv" ON)
option(DARTCV_WITH_STITCHING "Include stitching module of opencv" ON)
option(DARTCV_WITH_VIDEO "Include video module of opencv" ON)
option(DARTCV_WITH_VIDEOIO "Include objdetect module of opencv" OFF)
option(DARTCV_WITH_GAPI "Include gapi of opencv" OFF) # TODO: not finished
option(DARTCV_WORLD "Include all modules" OFF) # world means build all modules
option(DARTCV_ENABLE_INSTALL "Enable install" OFF)
option(DARTCV_ENABLE_TEST "Enable tests" OFF)
option(BUILD_WITH_STATIC_CRT "Build with static CRT" ON)
option(DARTCV_DISABLE_DOWNLOAD_OPENCV "Download opencv sdk from opencv.full" OFF)
#set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE INTERNAL "")
if (${DARTCV_WITH_HIGHGUI} OR ${DARTCV_WITH_VIDEOIO} OR ${DARTCV_WORLD})
set(DARTCV_WITH_FFMPEG ON CACHE BOOL "")
else ()
set(DARTCV_WITH_FFMPEG OFF CACHE BOOL "")
endif ()
if (NOT OPENCV_VERSION)
set(OPENCV_VERSION "4.10.0+10")
endif ()
# ============ download and prepare OpenCV =========
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif ()
include(cmake/download_setup_opencv.cmake)
if (UNIX AND NOT ANDROID)
find_package(Iconv REQUIRED)
endif ()
# ============ download and prepare OpenCV_DIR finished ==============
find_package(OpenCV REQUIRED)
if (DARTCV_WITH_HIGHGUI OR DARTCV_WITH_VIDEOIO OR DARTCV_WORLD)
find_package(FFMPEG REQUIRED)
endif ()
set(DARTCV_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "DARTCV_INCLUDE_DIRS")
add_subdirectory(dartcv)
if (DARTCV_ENABLE_INSTALL)
set(ROOT_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if (ANDROID)
message(STATUS "Installing ${FFMPEG_LIB_PATHS} to ${CMAKE_INSTALL_PREFIX}")
file(COPY ${FFMPEG_LIB_PATHS} DESTINATION ${CMAKE_INSTALL_PREFIX}/${ANDROID_ABI})
endif ()
# install
install(DIRECTORY ${ROOT_PROJECT_DIR}/dartcv
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
COMPONENT header_files
FILES_MATCHING
PATTERN "*.h"
PATTERN "t.h" EXCLUDE
PATTERN "test" EXCLUDE
PATTERN "build" EXCLUDE
)
install(FILES "${ROOT_PROJECT_DIR}/README.md" "${ROOT_PROJECT_DIR}/LICENSE"
DESTINATION ${CMAKE_INSTALL_PREFIX}
COMPONENT asset_files
)
install(TARGETS dartcv
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
COMPONENT target_libs
)
install(FILES ${FFMPEG_LIB_PATHS}
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
COMPONENT ffmpeg_libs
)
endif ()
if (DARTCV_ENABLE_TEST)
add_subdirectory(test)
endif ()