I think zig 0.17.0 will let you do it with Configure Cache Poisoning, specifically std.Build.dependOnDirectoryMetadata. That tells the ‘maker’ to rerun the ‘configurer’ if the directory contents changes. NB: it is not recursive.
That said, I recommend listing individual files. Unlike zig, C & C++ don’t have a mechanism for the compiler to determine what code is and isn’t used, so by listing them individually:
- It makes it easy for other people reading your project to see what it’s doing.
- Your build won’t fail because of a compile error in code you don’t use.