I have been using submodules to include projects inside "super-projects".
I am running into an annoyance though where I have the same submodule included several times in one super project.
For example, say I have a project called Helpers
.
Then I have a project, GeometryHelpers
, that includes Helpers
as a submodule.
Then I have another project called AlgebraHelpers
that includes Helpers
as a submodule.
So far so good, this lets me reuse my Helpers
code.
However, now say I have a project called Math
that has GeometryHelpers
and AlgebraHelpers
as submodules.
Now I have two copies of Helpers
(Math/GeometryHelpers/Helpers
and Math/AlgebraHelpers/Helpers
).
If I have to change something in Helpers
, I then have to make sure to not forget to update it in both places, or I could expect things to be out of sync.
My current update process if something in Helpers
changes (which happens regularly) is:
cd Math/GeometryHelpers/Helpers; git pull
cd ..; git add -u; git commit; git push # update the pointer to Helpers in GeometryHelpers
cd ../AlgebraHelpers/Helpers; git pull;
cd ..; git add -u; git push # update the pointer to Helpers in AlgebraHelpers
cd ..; git add -u; git push # update the pointers to AlgebraHelpers and GeometryHelpers in Math
It seems like the ideal case would be to have Math/Helpers, and have Math/AlgebraHelpers
and Math/GeometryHelpers
use the same Math/Helpers
.
But to setup something like this, it seems like it would be hard to maintain the ability to build AlgebraHelpers
in a standalone way (i.e. not inside Math).
I don't really want to build libraries and install them on the system somewhere because when I am working in GeometryHelpers
and want to update something in Helpers
, I'd have to go open the Helpers
project, build the library, and install it to wherever GeometryHelpers
is looking for it.
That is not a particularly smooth process, especially since Helpers
is changing frequently.
Is there a better way to handle this?
I am using CMake as my build system and all of these projects are c++ projects.