I have a CMake multi module project made of a library and an executable. Both the root project and each sub module has its own version (major.minor.patch).

I would like to know how to handle each version:

  • if root project changes version, each sub module goes through the same change
  • if a sub module changes version, what should happen to super project and to other module?

My doubt is that, propagating sub module changes to root makes its version a mix of all changes.

Suppose you are starting from:

  • root 1.0.0
  • lib 1.0.0
  • exe 1.0.0

then you made a minor fix to lib and a path to exe:

  • lib 1.1.0
  • exe 1.0.1

Should root version be 1.1.1? Is it meaningful?

What if both changes are minor fix? Root should increment to 1.1.0 or to 1.2.0 (the "sum" of each module minor fix)?

  • Why do you have the root version? Who would refer to the root version rather than the library or executable version and what information does a change in the root version convey to them? – Bart van Ingen Schenau Apr 9 '18 at 9:57
  • It is a container to run some global targets (i.e. the CPack configuration is defined at root level). I thought that it were not a good idea to have a root project without a version (actually I think that having any project without a version is not a goog idea) – Marco Stramezzi Apr 10 '18 at 6:42

Both the root project and each sub module has its own version (major.minor.patch)

Why? I'd contend that this decision was a mistake and has created the problem situation you are asking for help with, whilst offering no advantages in return.

Have one version number that all parts of project share. It simplifies things, makes the project appear more coherent and avoids the whole "if I change X, what version should Y now be at?" issue completely. Problem solved.

| improve this answer | |
  • yes, but how to handle it with CMake? It does not seem to have "version inheritance" like, for example, Maven. If I do not specify a version in sub modules, they do not have a version at all (for what I understood about CMake behavior) – Marco Stramezzi Apr 9 '18 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.