Opencv cuda enabled build example for CUDA compute capability 8.9, such as RTX 4090

I want to ask how to build opencv with CUDA enabled with some new GPU, such like RTX 4090 which compute capability is 8.9.

My building os will be in ubuntu 18.04 or 20.04, or 22.04

If you are using commits after 09/01/23 then simply adding


to your CMake arguments will build for all compute capabilities including 8.9 and 9.0.

If not and/or you want to reduce the build time, you just need to add


to build binary compatible code for compute capability 8.9 only. Note this will not generate the corresponding PTX so the OpenCV CUDA functions will not work on compute capability >= 9.0 devices.