--- a/cmake/templates/OpenCV.mk.in
+++ b/cmake/templates/OpenCV.mk.in
@@ -2,6 +2,13 @@
 # you might need to define NDK_USE_CYGPATH=1 before calling the ndk-build
 
 USER_LOCAL_PATH:=$(LOCAL_PATH)
+
+USER_LOCAL_C_INCLUDES:=$(LOCAL_C_INCLUDES)
+USER_LOCAL_CFLAGS:=$(LOCAL_CFLAGS)
+USER_LOCAL_STATIC_LIBRARIES:=$(LOCAL_STATIC_LIBRARIES)
+USER_LOCAL_SHARED_LIBRARIES:=$(LOCAL_SHARED_LIBRARIES)
+USER_LOCAL_LDLIBS:=$(LOCAL_LDLIBS)
+
 LOCAL_PATH:=$(subst ?,,$(firstword ?$(subst \, ,$(subst /, ,$(call my-dir)))))
 
 OPENCV_TARGET_ARCH_ABI:=$(TARGET_ARCH_ABI)
@@ -13,7 +20,7 @@
 OPENCV_LOCAL_C_INCLUDES:=@OPENCV_INCLUDE_DIRS_CONFIGCMAKE@
 OPENCV_MODULES:=@OPENCV_MODULES_CONFIGMAKE@
 
-OPENCV_HAVE_GPU_MODULE=@OPENCV_HAVE_GPU_MODULE_CONFIGMAKE@
+OPENCV_HAVE_GPU_MODULE:=@OPENCV_HAVE_GPU_MODULE_CONFIGMAKE@
 OPENCV_USE_GPU_MODULE:=
 
 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
@@ -22,9 +29,12 @@
             OPENCV_USE_GPU_MODULE:=on
         endif
     endif
-endif
-
-CUDA_RUNTIME_LIBS:=cufft npps nppi nppc cudart
+    OPENCV_DYNAMICUDA_MODULE:=@OPENCV_DYNAMICUDA_MODULE_CONFIGMAKE@
+else
+    OPENCV_DYNAMICUDA_MODULE:=
+endif
+
+CUDA_RUNTIME_LIBS:=@CUDA_RUNTIME_LIBS_CONFIGMAKE@
 
 ifeq ($(OPENCV_LIB_TYPE),)
     OPENCV_LIB_TYPE:=@OPENCV_LIBTYPE_CONFIGMAKE@
@@ -60,7 +70,7 @@
     endif
 endif
 
-ifeq (${OPENCV_CAMERA_MODULES},on)
+ifeq ($(OPENCV_CAMERA_MODULES),on)
     ifeq ($(TARGET_ARCH_ABI),armeabi)
         OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_ARMEABI_CONFIGCMAKE@
     endif
@@ -91,6 +101,13 @@
     include $(PREBUILT_$(OPENCV_LIB_TYPE)_LIBRARY)
 endef
 
+define add_cuda_module
+    include $(CLEAR_VARS)
+    LOCAL_MODULE:=$1
+    LOCAL_SRC_FILES:=$(CUDA_TOOLKIT_DIR)/targets/armv7-linux-androideabi/lib/lib$1.so
+    include $(PREBUILT_SHARED_LIBRARY)
+endef
+
 define add_opencv_3rdparty_component
     include $(CLEAR_VARS)
     LOCAL_MODULE:=$1
@@ -108,6 +125,17 @@
 ifeq ($(OPENCV_MK_$(OPENCV_TARGET_ARCH_ABI)_ALREADY_INCLUDED),)
     ifeq ($(OPENCV_INSTALL_MODULES),on)
         $(foreach module,$(OPENCV_LIBS),$(eval $(call add_opencv_module,$(module))))
+        ifneq ($(OPENCV_DYNAMICUDA_MODULE),)
+            ifeq ($(OPENCV_LIB_TYPE),SHARED)
+              $(eval $(call add_opencv_module,$(OPENCV_DYNAMICUDA_MODULE)))
+            endif
+        endif
+    endif
+
+    ifeq ($(OPENCV_USE_GPU_MODULE),on)
+        ifeq ($(INSTALL_CUDA_LIBRARIES),on)
+            $(foreach module,$(CUDA_RUNTIME_LIBS),$(eval $(call add_cuda_module,$(module))))
+        endif
     endif
 
     $(foreach module,$(OPENCV_3RDPARTY_COMPONENTS),$(eval $(call add_opencv_3rdparty_component,$(module))))
@@ -136,6 +164,13 @@
 endif
 
 include $(CLEAR_VARS)
+
+LOCAL_C_INCLUDES:=$(USER_LOCAL_C_INCLUDES)
+LOCAL_CFLAGS:=$(USER_LOCAL_CFLAGS)
+LOCAL_STATIC_LIBRARIES:=$(USER_LOCAL_STATIC_LIBRARIES)
+LOCAL_SHARED_LIBRARIES:=$(USER_LOCAL_SHARED_LIBRARIES)
+LOCAL_LDLIBS:=$(USER_LOCAL_LDLIBS)
+
 LOCAL_C_INCLUDES += $(OPENCV_LOCAL_C_INCLUDES)
 LOCAL_CFLAGS     += $(OPENCV_LOCAL_CFLAGS)
 
@@ -145,6 +180,11 @@
 
 ifeq ($(OPENCV_INSTALL_MODULES),on)
     LOCAL_$(OPENCV_LIB_TYPE)_LIBRARIES += $(foreach mod, $(OPENCV_LIBS), opencv_$(mod))
+    ifeq ($(OPENCV_LIB_TYPE),SHARED)
+        ifneq ($(OPENCV_DYNAMICUDA_MODULE),)
+            LOCAL_$(OPENCV_LIB_TYPE)_LIBRARIES += $(OPENCV_DYNAMICUDA_MODULE)
+        endif
+    endif
 else
     LOCAL_LDLIBS += -L$(call host-path,$(LOCAL_PATH)/$(OPENCV_LIBS_DIR)) $(foreach lib, $(OPENCV_LIBS), -lopencv_$(lib))
 endif
@@ -156,8 +196,12 @@
 LOCAL_LDLIBS += $(foreach lib,$(OPENCV_EXTRA_COMPONENTS), -l$(lib))
 
 ifeq ($(OPENCV_USE_GPU_MODULE),on)
+    ifeq ($(INSTALL_CUDA_LIBRARIES),on)
+        LOCAL_SHARED_LIBRARIES += $(foreach mod, $(CUDA_RUNTIME_LIBS), $(mod))
+    else
+        LOCAL_LDLIBS += -L$(CUDA_TOOLKIT_DIR)/targets/armv7-linux-androideabi/lib $(foreach lib, $(CUDA_RUNTIME_LIBS), -l$(lib))
+    endif
     LOCAL_STATIC_LIBRARIES+=libopencv_gpu
-    LOCAL_LDLIBS += -L$(CUDA_TOOLKIT_DIR)/lib $(foreach lib, $(CUDA_RUNTIME_LIBS), -l$(lib))
 endif
 
 #restore the LOCAL_PATH