OpenCV C++ CUDA build error

I think it is getting farther than before, but it is now getting stuck here:

/home/ubuntu/OpenCV/opencv_contrib/modules/cudastereo/src/cuda/stereosgm.cu(382):
error: Within a device/global function, only shared
variables may be marked “static”

/home/ubuntu/OpenCV/opencv_contrib/modules/cudastereo/src/cuda/stereosgm.cu(584):
error: Within a device/global function, only shared
variables may be marked “static”
detected during instantiation of “void
cv::cuda::device::stereosgm::path_aggregation::horizontal::aggregateLeft2RightPath<MAX_DISPARITY>(const
cv::cuda::GpuMat &, const cv::cuda::GpuMat &, cv::cuda::GpuMat &,
unsigned int, unsigned int, int, cv::cuda::Stream &) [with
MAX_DISPARITY=64U]”
(769): here