I've got a C++ project that builds in several configurations (not just Debug/Release), and it's a rather massive project. Let's call it KitchenSink.vcproj
I suspect that many pieces of this project build identically, regardless of the configuration. E.g. Building with/without Unicode support will not matter for a source file that doesn't use strings.
This would lead to the same source file being compiled in multiple configurations, but generating (effectively) the same .obj file. It doesn't generate the same file, because timestamps and the like are embedded in the file, but all the functional pieces of the object file would be the same.
Is there a way to check this? I would like to extract pieces of KitchenSink to their own, simpler, projects, where they only need to be built once. This would speed up build times, and simplify our codebase. But I need a way to automatically find the parts of the code that build the same, regardless of configuration. Is there an easy way to do that?
EDIT: Clarifying my point. Imagine the following file:
// Some header file
int calculate_something(int a, int b);
// The source file
int calculate_something(int a, int b) {
return a * b;
}
Now, that source file has nothing to do with Unicode. So, if we build it in a Unicode configuration, and then build it again with a MultiByte configuration, we're just wasting time. We could put it into its own static library, that's built without Unicode support, and then that new lib could be used by my other projects. There's nothing risky in that.
I just need to find these files that can be safely moved to a separate project.
EDIT: Further clarification:
KitchenSink.vcproj has the following files (among others)
StringUtils.h
StringUtils.cpp
MathStuff.h
MathStuff.cpp
Now, if you build KitchenSink in Unicode, and again in MultiByte, you will build StringUtils.obj twice, and MathStuff.obj twice. Obviously, this is necessary for StringUtils.obj, since it will be different in Unicode and MultiByte. But MathStuff.obj should build the exact same.
So, I would like to rearrange/restructure/refactor to the following:
KitchenSink.vcproj has the following files (among others)
StringUtils.h
StringUtils.cpp
NewProject.vcproj has the following files
MathStuff.h
MathStuff.cpp
Now, KitchenSink can be built in its multiple configurations, while NewProject can be built with just a single Debug/Release option.
Again, I'm NOT talking about SHARING obj files. I'm talking about removing cpp/h files from one project, and putting them in another.
Also note that Unicode/Multibyte is an example of a project with multiple configurations. The reality in my project is actually more complicated, so each source file is compiled 4 times, rather than the 2 that would occur with Unicode/Multibyte.