forked from opencv/opencv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOpenCVGenAndroidMK.cmake
143 lines (122 loc) · 6.24 KB
/
OpenCVGenAndroidMK.cmake
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
if(ANDROID)
# --------------------------------------------------------------------------------------------
# Installation for Android ndk-build makefile: OpenCV.mk
# Part 1/2: ${BIN_DIR}/OpenCV.mk -> For use *without* "make install"
# Part 2/2: ${BIN_DIR}/unix-install/OpenCV.mk -> For use with "make install"
# -------------------------------------------------------------------------------------------
# build type
if(BUILD_SHARED_LIBS)
set(OPENCV_LIBTYPE_CONFIGMAKE "SHARED")
else()
set(OPENCV_LIBTYPE_CONFIGMAKE "STATIC")
endif()
if(BUILD_FAT_JAVA_LIB)
set(OPENCV_LIBTYPE_CONFIGMAKE "SHARED")
set(OPENCV_STATIC_LIBTYPE_CONFIGMAKE "STATIC")
else()
set(OPENCV_STATIC_LIBTYPE_CONFIGMAKE ${OPENCV_LIBTYPE_CONFIGMAKE})
endif()
# setup lists of camera libs
foreach(abi ARMEABI ARMEABI_V7A X86 MIPS)
ANDROID_GET_ABI_RAWNAME(${abi} ndkabi)
if(BUILD_ANDROID_CAMERA_WRAPPER)
if(ndkabi STREQUAL ANDROID_NDK_ABI_NAME)
set(OPENCV_CAMERA_LIBS_${abi}_CONFIGCMAKE "native_camera_r${ANDROID_VERSION}")
else()
set(OPENCV_CAMERA_LIBS_${abi}_CONFIGCMAKE "")
endif()
elseif(HAVE_opencv_androidcamera)
set(OPENCV_CAMERA_LIBS_${abi}_CONFIGCMAKE "")
file(GLOB OPENCV_CAMERA_LIBS "${OpenCV_SOURCE_DIR}/3rdparty/lib/${ndkabi}/libnative_camera_r*.so")
if(OPENCV_CAMERA_LIBS)
list(SORT OPENCV_CAMERA_LIBS)
endif()
foreach(cam_lib ${OPENCV_CAMERA_LIBS})
get_filename_component(cam_lib "${cam_lib}" NAME)
string(REGEX REPLACE "lib(native_camera_r[0-9]+\\.[0-9]+\\.[0-9]+)\\.so" "\\1" cam_lib "${cam_lib}")
set(OPENCV_CAMERA_LIBS_${abi}_CONFIGCMAKE "${OPENCV_CAMERA_LIBS_${abi}_CONFIGCMAKE} ${cam_lib}")
endforeach()
endif()
endforeach()
# build the list of opencv libs and dependencies for all modules
set(OPENCV_MODULES_CONFIGMAKE "")
set(OPENCV_HAVE_GPU_MODULE_CONFIGMAKE "off")
set(OPENCV_EXTRA_COMPONENTS_CONFIGMAKE "")
set(OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE "")
foreach(m ${OPENCV_MODULES_PUBLIC})
list(INSERT OPENCV_MODULES_CONFIGMAKE 0 ${${m}_MODULE_DEPS_${ocv_optkind}} ${m})
if(${m}_EXTRA_DEPS_${ocv_optkind})
list(INSERT OPENCV_EXTRA_COMPONENTS_CONFIGMAKE 0 ${${m}_EXTRA_DEPS_${ocv_optkind}})
endif()
endforeach()
# remove CUDA runtime and NPP from regular deps
# it can be added separately if needed.
ocv_list_filterout(OPENCV_EXTRA_COMPONENTS_CONFIGMAKE "libcu")
ocv_list_filterout(OPENCV_EXTRA_COMPONENTS_CONFIGMAKE "libnpp")
if(HAVE_CUDA)
# CUDA runtime libraries and are required always
set(culibs ${CUDA_LIBRARIES})
# right now NPP is requared always too
list(INSERT culibs 0 ${CUDA_npp_LIBRARY})
if(HAVE_CUFFT)
list(INSERT culibs 0 ${CUDA_cufft_LIBRARY})
endif()
if(HAVE_CUBLAS)
list(INSERT culibs 0 ${CUDA_cublas_LIBRARY})
endif()
endif()
ocv_convert_to_lib_name(CUDA_RUNTIME_LIBS_CONFIGMAKE ${culibs})
# split 3rdparty libs and modules
foreach(mod ${OPENCV_MODULES_CONFIGMAKE})
if(NOT mod MATCHES "^opencv_.+$")
list(INSERT OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE 0 ${mod})
endif()
endforeach()
if(OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE)
list(REMOVE_ITEM OPENCV_MODULES_CONFIGMAKE ${OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE})
endif()
if(ENABLE_DYNAMIC_CUDA)
set(OPENCV_DYNAMICUDA_MODULE_CONFIGMAKE "dynamicuda")
endif()
# GPU module enabled separately
list(REMOVE_ITEM OPENCV_MODULES_CONFIGMAKE "opencv_gpu")
list(REMOVE_ITEM OPENCV_MODULES_CONFIGMAKE "opencv_dynamicuda")
if(HAVE_opencv_gpu)
set(OPENCV_HAVE_GPU_MODULE_CONFIGMAKE "on")
endif()
# convert CMake lists to makefile literals
foreach(lst OPENCV_MODULES_CONFIGMAKE OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE OPENCV_EXTRA_COMPONENTS_CONFIGMAKE)
ocv_list_unique(${lst})
ocv_list_reverse(${lst})
string(REPLACE ";" " " ${lst} "${${lst}}")
endforeach()
string(REPLACE "opencv_" "" OPENCV_MODULES_CONFIGMAKE "${OPENCV_MODULES_CONFIGMAKE}")
string(REPLACE ";" " " CUDA_RUNTIME_LIBS_CONFIGMAKE "${CUDA_RUNTIME_LIBS_CONFIGMAKE}")
# prepare 3rd-party component list without TBB for armeabi and mips platforms. TBB is useless there.
set(OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB ${OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE})
foreach(mod ${OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB})
string(REPLACE "tbb" "" OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB "${OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB}")
endforeach()
if(BUILD_FAT_JAVA_LIB)
set(OPENCV_LIBS_CONFIGMAKE java)
else()
set(OPENCV_LIBS_CONFIGMAKE "${OPENCV_MODULES_CONFIGMAKE}")
endif()
# -------------------------------------------------------------------------------------------
# Part 1/2: ${BIN_DIR}/OpenCV.mk -> For use *without* "make install"
# -------------------------------------------------------------------------------------------
set(OPENCV_INCLUDE_DIRS_CONFIGCMAKE "\"${OPENCV_CONFIG_FILE_INCLUDE_DIR}\" \"${OpenCV_SOURCE_DIR}/include\" \"${OpenCV_SOURCE_DIR}/include/opencv\"")
set(OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE "\"${OpenCV_SOURCE_DIR}\"")
set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/lib/\$(OPENCV_TARGET_ARCH_ABI)")
set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/3rdparty/lib/\$(OPENCV_TARGET_ARCH_ABI)")
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/OpenCV.mk" @ONLY)
# -------------------------------------------------------------------------------------------
# Part 2/2: ${BIN_DIR}/unix-install/OpenCV.mk -> For use with "make install"
# -------------------------------------------------------------------------------------------
set(OPENCV_INCLUDE_DIRS_CONFIGCMAKE "\"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/include/opencv\" \"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/include\"")
set(OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE "")
set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../libs/\$(OPENCV_TARGET_ARCH_ABI)")
set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../3rdparty/libs/\$(OPENCV_TARGET_ARCH_ABI)")
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk" @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk DESTINATION ${OPENCV_CONFIG_INSTALL_PATH} COMPONENT dev)
endif(ANDROID)