Full error message:
fatal error C1041: cannot open program database 'c:\develop\3rdparty\_test_build_opencv_3_2\opencv_3_2\build\modules\cudaarithm\cmakefiles\cuda_compile.dir\src\cuda\vc120.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS
Cmake generates the VS Solution and in this process it spawns cuda tasks.
It seems that there is a PDB conflict since several cl trying to write to the same PDB file.
In normal VS projects it is possible to pass the /FS flag to the host compiler which which will solve the pdb access problem.
Cmake-generated projects, however, don't have the CUDA C/C++ section in the projects properties, so there is no easy way to set that flag from CMake.
Using the advanced cmake properties CMAKE_C_FLAGS and CMAKE_CXX_FLAGS combined with the CUDA_PROPAGATE_HOST_FLAGS flag, it is possible to pass the /FS option down to the host compiler used by nvcc, which was causing the concurrent access to the pdb files.
Now compilation can runs smoothly on all cores.