Is it possible for the SPM to compile Cuda files and build a lib?

It isn't currently possible to delegate to other build systems in SwiftPM. It's a goal to allow extending integrating other build tools in SwiftPM but it requires considerable design discussions. There was a draft posted here a while back.

However, you can use the -Xcc/-Xswiftc/-Xlinker escape hatches to provide custom compiler flags. Something like this should work: swift build -Xswiftc -I/path/to/headers -Xlinker -lsomelib.