Automatically add CUDA support to a module if it has CUDA sources.

Backport from master.
Merge pull request #793 from SpecLad:auto-cuda