cudabgsegm module was not compiling.  Changing all references of opencv2/legacy.hpp to opencv2/cudalegacy.hpp seemed to work.
I'm new at this so it would be good to have someone familiar with the build system confirm the change.