opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

CMake fails with generator Ninja Multi-Config when including WITH_CUDA

Open cudawarped opened this issue 3 years ago • 2 comments

System information (version)
  • OpenCV => 4.5.5
  • Operating System / Platform => Windows 10 64 Bit, Ubuntu 20.04 LTS
  • Compiler => Visual Studio 2019, gcc version 9.3.0
Detailed description

On windows and linux passing the generator Ninja Multi-Config works until WITH_CUDA is selected, then CMake configuration fails with lots of errors similar to

 CMake Error at cmake/OpenCVUtils.cmake:1547 (add_library):
   Legacy variable expansion in source file
   "D:/build/opencv/modules/superres/CMakeFiles/cuda_compile_1.dir/src/cuda/${CONFIGURATION}/cuda_compile_1_generated_btv_l1_gpu.cu.obj"
   expanded to
   "D:/build/opencv/modules/superres/CMakeFiles/cuda_compile_1.dir/src/cuda//cuda_compile_1_generated_btv_l1_gpu.cu.obj"
   in target "opencv_superres".  This behavior will be removed in a future
   version of CMake.
 Call Stack (most recent call first):
   cmake/OpenCVModule.cmake:966 (ocv_add_library)
   cmake/OpenCVModule.cmake:882 (_ocv_create_module)
   cmake/OpenCVModule.cmake:1108 (ocv_create_module)
   D:/repos/opencv/contrib/modules/superres/CMakeLists.txt:9 (ocv_define_module)
Steps to reproduce
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
"C:\Program Files\CMake\bin\cmake.exe" . -G"Ninja Multi-Config" -DOPENCV_EXTRA_MODULES_PATH="../contrib/modules" -B"D:/build/opencv" -DWITH_CUDA=ON 
Issue submission checklist
  • [x] I report the issue, it's not a question
  • [x] I checked the problem with documentation, FAQ, open issues, answers.opencv.org, Stack Overflow, etc and have not found solution
  • [x] I updated to latest OpenCV version and the issue is still there
  • [x] There is reproducer code and related data files: videos, images, onnx, etc

cudawarped avatar Dec 30 '21 18:12 cudawarped

Hello @cudawarped

This seems to be a CMake issue. I could reproduce it with CMake alone:

cmake_minimum_required(VERSION 3.5.1)
project( cuda1 LANGUAGES CXX C)

find_package(CUDA REQUIRED)
cuda_add_executable( cuda1 main.cu )

I got similar errors

CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/FindCUDA.cmake:2035 (add_executable):
Legacy variable expansion in source file
"D:/cuda1/build/CMakeFiles/cuda1.dir//${CONFIGURATION}/cuda1_generated_main.cu.obj"         expanded to
"D:/cuda1/build/CMakeFiles/cuda1.dir///cuda1_generated_main.cu.obj"
in target "cuda1".  This behavior will be removed in a future version of CMake.            

I have reported it to CMake: https://gitlab.kitware.com/cmake/cmake/-/issues/22124#note_1147195

r2d3 avatar Feb 22 '22 22:02 r2d3

Opened a specific issue for this FindCUDA issue : https://gitlab.kitware.com/cmake/cmake/-/issues/23258

r2d3 avatar Feb 22 '22 22:02 r2d3