I generally go the unity build route for as long as I can. When I have to get back compilation speed I do it by moving a large chunk into a separate static (.lib/.a) or shared (.dll/.so) file and I have different scripts for each chunk (or something like that).
If you're not familiar with the unity build, it's just where you go:
cl <all my options> my_target_file.cpp
Then in the target file you'll see something similar to:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | // TOP
#include "foo.h"
#include "bar.h"
#include "baz.h"
// maybe some code, maybe not
#include "foo.cpp"
#include "bar.cpp"
#include "foobar.cpp"
// probably more code
int main(){
// etc
}
// BOTTOM
|
Of course if you wanted to avoid a list of files you haven't really achieved that, it's just an include list instead of a .bat list, but this does just work out nicer anyway. It makes fewer .obj files. It's a nicer syntax, at least for me. You get an error jumping you to the correct file and line when there's a misspelling.
If you're really worried about having to list all your .cpp and .h files, you can still just do "cl *.cpp", but I think the list of files is worth it.