Added generation of OpenCV.mk file for Android development with ndk-build tool
This commit is contained in:
parent
ee2aefc270
commit
9c71134caf
@ -1230,6 +1230,49 @@ if(WIN32)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/cvconfig.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
|
||||
endif()
|
||||
|
||||
# --------------------------------------------------------------------------------------------
|
||||
# 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"
|
||||
# -------------------------------------------------------------------------------------------
|
||||
if(ANDROID)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
SET(OPENCV_LIBTYPE_CONFIGMAKE "SHARED")
|
||||
else()
|
||||
SET(OPENCV_LIBTYPE_CONFIGMAKE "STATIC")
|
||||
endif()
|
||||
if(BUILD_ANDROID_CAMERA_WRAPPER)
|
||||
set(CMAKE_CAMERA_LIBS_CONFIGCMAKE "native_camera_r${ANDROID_VERSION}")
|
||||
else()
|
||||
SET(CMAKE_CAMERA_LIBS_CONFIGCMAKE "")
|
||||
file(GLOB CMAKE_CAMERA_LIBS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/lib/libnative_camera_r*.so")
|
||||
foreach(cam_lib ${CMAKE_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(CMAKE_CAMERA_LIBS_CONFIGCMAKE "${CMAKE_CAMERA_LIBS_CONFIGCMAKE} ${cam_lib}")
|
||||
endforeach()
|
||||
endif()
|
||||
endif(ANDROID)
|
||||
# -------------------------------------------------------------------------------------------
|
||||
# Part 1/2: ${BIN_DIR}/OpenCV.mk -> For use *without* "make install"
|
||||
# -------------------------------------------------------------------------------------------
|
||||
if(ANDROID)
|
||||
set(CMAKE_INCLUDE_DIRS_CONFIGCMAKE "\"\$(RELATIVE_PREFIX)${OPENCV_CONFIG_FILE_INCLUDE_DIR}\" \"\$(RELATIVE_PREFIX)${CMAKE_CURRENT_SOURCE_DIR}/include\" \"\$(RELATIVE_PREFIX)${CMAKE_CURRENT_SOURCE_DIR}/include/opencv\"")
|
||||
set(CMAKE_BASE_INCLUDE_DIRS_CONFIGCMAKE "\"\$(RELATIVE_PREFIX)${CMAKE_CURRENT_SOURCE_DIR}\"")
|
||||
set(CMAKE_LIB_DIRS_CONFIGCMAKE "\$(RELATIVE_PREFIX)${LIBRARY_OUTPUT_PATH}")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/OpenCV.mk" IMMEDIATE @ONLY)
|
||||
endif(ANDROID)
|
||||
|
||||
# -------------------------------------------------------------------------------------------
|
||||
# Part 2/2: ${BIN_DIR}/unix-install/OpenCV.mk -> For use with "make install"
|
||||
# -------------------------------------------------------------------------------------------
|
||||
if(ANDROID)
|
||||
set(CMAKE_INCLUDE_DIRS_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../../include/opencv \$(OPENCV_THIS_DIR)/../../include")
|
||||
set(CMAKE_BASE_INCLUDE_DIRS_CONFIGCMAKE "")
|
||||
set(CMAKE_LIB_DIRS_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../../lib")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk" IMMEDIATE @ONLY)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk DESTINATION share/opencv/)
|
||||
endif(ANDROID)
|
||||
|
||||
# --------------------------------------------------------------------------------------------
|
||||
# Part 2/2: ${BIN_DIR}/unix-install/opencv.pc -> For use *with* "make install"
|
||||
|
57
OpenCV.mk.in
Normal file
57
OpenCV.mk.in
Normal file
@ -0,0 +1,57 @@
|
||||
RELATIVE_PREFIX:=.$(shell echo $(abspath $(LOCAL_PATH))| sed -e "s/\/[^\/]*/\/../g" )
|
||||
OPENCV_THIS_DIR:=$(RELATIVE_PREFIX)$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
OPENCV_LIBS_DIR:=@CMAKE_LIB_DIRS_CONFIGCMAKE@
|
||||
OPENCV_BASEDIR:=@CMAKE_BASE_INCLUDE_DIRS_CONFIGCMAKE@
|
||||
OPENCV_LOCAL_C_INCLUDES:=@CMAKE_INCLUDE_DIRS_CONFIGCMAKE@
|
||||
|
||||
OPENCV_MODULES := contrib calib3d objdetect features2d imgproc video highgui ml legacy flann core
|
||||
|
||||
OPENCV_LIB_TYPE:=@OPENCV_LIBTYPE_CONFIGMAKE@
|
||||
ifeq ($(OPENCV_LIB_TYPE),SHARED)
|
||||
OPENCV_LIB_SUFFIX:=so
|
||||
OPENCV_EXTRA_COMPONENTS:=
|
||||
else
|
||||
OPENCV_LIB_SUFFIX:=a
|
||||
OPENCV_MODULES+= androidcamera
|
||||
OPENCV_EXTRA_COMPONENTS:=@JPEG_LIBRARIES@ @PNG_LIBRARIES@ @TIFF_LIBRARIES@ @JASPER_LIBRARIES@ zlib
|
||||
endif
|
||||
|
||||
OPENCV_CAMERA_MODULES := @CMAKE_CAMERA_LIBS_CONFIGCMAKE@
|
||||
|
||||
define add_opencv_module
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE:=opencv_$1
|
||||
LOCAL_SRC_FILES:=$(OPENCV_LIBS_DIR)/libopencv_$1.$(OPENCV_LIB_SUFFIX)
|
||||
include $(PREBUILT_@OPENCV_LIBTYPE_CONFIGMAKE@_LIBRARY)
|
||||
endef
|
||||
|
||||
define add_opencv_extra_component
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE:=$1
|
||||
LOCAL_SRC_FILES:=$(OPENCV_THIS_DIR)/3rdparty/lib/lib$1.a
|
||||
include $(PREBUILT_STATIC_LIBRARY)
|
||||
endef
|
||||
|
||||
define add_opencv_camera_module
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE:=$1
|
||||
LOCAL_SRC_FILES:=$(OPENCV_LIBS_DIR)/lib$1.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
endef
|
||||
|
||||
$(foreach module,$(OPENCV_MODULES),$(eval $(call add_opencv_module,$(module))))
|
||||
$(foreach module,$(OPENCV_EXTRA_COMPONENTS),$(eval $(call add_opencv_extra_component,$(module))))
|
||||
$(foreach module,$(OPENCV_CAMERA_MODULES),$(eval $(call add_opencv_camera_module,$(module))))
|
||||
|
||||
ifneq ($(OPENCV_BASEDIR),)
|
||||
OPENCV_LOCAL_C_INCLUDES += $(foreach mod, $(OPENCV_MODULES), $(OPENCV_BASEDIR)/modules/$(mod)/include)
|
||||
endif
|
||||
|
||||
OPENCV_LOCAL_LIBRARIES += $(foreach mod, $(OPENCV_MODULES), opencv_$(mod))
|
||||
OPENCV_LOCAL_LIBRARIES += $(OPENCV_EXTRA_COMPONENTS)
|
||||
OPENCV_LOCAL_CFLAGS := -fsigned-char -fPIC -DANDROID
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_C_INCLUDES += $(OPENCV_LOCAL_C_INCLUDES)
|
||||
LOCAL_STATIC_LIBRARIES += $(OPENCV_LOCAL_LIBRARIES)
|
||||
LOCAL_CFLAGS += $(OPENCV_LOCAL_CFLAGS)
|
@ -59,7 +59,7 @@ else()
|
||||
#libraries order is very important because linker from Android NDK is one-pass linker
|
||||
set(OPENCV_LIB_COMPONENTS opencv_contrib opencv_calib3d opencv_objdetect opencv_features2d opencv_imgproc opencv_video opencv_highgui opencv_ml opencv_legacy opencv_flann opencv_core )
|
||||
IF (NOT @BUILD_SHARED_LIBS@)
|
||||
set(OPENCV_LIB_COMPONENTS opencv_androidcamera ${OPENCV_LIB_COMPONENTS})
|
||||
set(OPENCV_LIB_COMPONENTS ${OPENCV_LIB_COMPONENTS} opencv_androidcamera)
|
||||
ENDIF()
|
||||
endif()
|
||||
|
||||
|
1
android/README.android
Normal file
1
android/README.android
Normal file
@ -0,0 +1 @@
|
||||
See http://opencv.willowgarage.com/wiki/Android
|
@ -1 +0,0 @@
|
||||
See http://opencv.willowgarage.com/wiki/AndroidTrunk
|
Loading…
Reference in New Issue
Block a user