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

Backport from master.