With USE="-contrib cuda -download" the following error occurs:
CMake Error at modules/core/CMakeLists.txt:40 (message):
CUDA: OpenCV requires enabled 'cudev' module from 'opencv_contrib'
However, the combination USE="contrib cuda -download", causes the following additional error:
/tmp/portage/media-libs/opencv-4.1.2-r2/work/opencv-4.1.2/modules/core/include/opencv2/core/base.hpp:320:40: error: expected constructor, destructor, or type conversion before ‘(’ token
#define CV_Error( code, msg ) cv::error( code, msg, CV_Func, __FILE__, __LINE__ )
/tmp/portage/media-libs/opencv-4.1.2-r2/work/opencv_contrib-4.1.2/modules/cudaoptflow/src/nvidiaOpticalFlow.cpp:15:1: note: in expansion of macro ‘CV_Error’
CV_Error(cv::Error::HeaderIsNull, "Nvidia Optical Flow headers not found. Make sure cmake downloads it properly");
However, USE="contrib cuda download" will also "fail" if FEATURES="network-sandbox":
-- ADE: Download: v0.1.1f.zip
-- Try 1 failed
Couldn't download files from the Internet.
Please check the Internet access on this host.
CMake Warning at cmake/OpenCVDownload.cmake:203 (message):
ADE: Download failed: 6;"Couldn't resolve host name"
For details please refer to the download log file:
This will not cause cmake to stop and it will try building as if USE=-download. (This could easily be missed and is inconsistent with the USE flag, leading to the above "Nvidia Optical Flow headers not found" error.)
I can confirm this issue.
Moreover, even if I installl the =media-libs/opencv-4.1.2-r2 with USE="contrib cuda download" and FEATURES="-network-sandbox", the "pkg-config --cflags opencv4" misses the following include path on my system:
Once this is added to CFLAGS in my Makefile, everything works properly.
Also USE="cuda" does not work with gcc > 8.3
Same issue here.
I will test with David Bařina suggestions.
I have tried to run cuda_sanitize (from cuda.eclass) to try to get right gcc version used by it still fails :/
Maybe it is not respecting NVCCFLAGS variable. It seems detection is done using variables like NVCC_FLAGS_EXTRA