Error compiling project that requires CUDA and CMAKE

I am doing a project to detect objects in images. I have the project with CMAKE, and when I want to compile, I do:

"C: \ Program Files (x86) \ Microsoft Visual Studio \ 2019 \ Community \ VC \ Auxiliary \ Build \ vcvarsall.bat" x86_amd64

and then:

cmake -G " NMake Makefiles "-DCMAKE_BUILD_TYPE = Release ..

I always receive this error:

Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.2/bin/nvcc.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/CMakeTestCUDACompiler.cmake:46 (message):
  The CUDA compiler

    "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.2/bin/nvcc.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: E:/yoloCuda/carpeta/CMakeFiles/CMakeTmp

I am using Microsoft Visual Studio 2017 and 2019, and CUDA V9.2 and I have also tried 10.1 and 10.2
Can somebody help me? I’ve been with this for two weeks. Thank you.

Probably you use cmake 3.17, which introduced a findCUDAtoolkit that does not work correctly and produces this error. Downgrade to the previous version 3.16.