Another way to do it, if you think separate projects is overkill, is by switching between different build configurations. Suppose you had a single main() function in a file called Main.cpp:
Then suppose you had three test programs called Prog1, Prog2, and Prog3. Instead of these programs having a main(), they have a function called Prog1(), Prog2(), or Prog3() respectively.
int main( int argc, char **argv )
return MAIN( argc, argv );
Now, in the build configuration manager, you can create three separate builds for each of these, with the difference between the builds being the preprocessor definition MAIN=Prog1, MAIN=Prog2, or MAIN=Prog3 respectively.
The unused ProgX.cpp modules won't get linked into the final executable, because their symbols are not (shouldn't be) referenced.