Reputation: 936
I'm writing an open source c++ library and would like to manage its versions. For example: label each release, label versions that are not yet released, etc. I would like people who download the pre compiled library to know the version they are using and maybe manage several version of the library in parallel. This library compiles only as static library (and not as dynamic). I'm not using cmake (which I know supports version labeling). What are the recommended ways to do that? Should I add an H file containing the current version? What should it include? Maybe some other idea?
Upvotes: 3
Views: 3618
Reputation: 8501
Personally, I like adding a configuration header file for every library I write. This allows my library's users to easily understand possible configurations and adjust it to their needs.
Regarding the version management, I usually add three version variables to that file:
static const unsigned VERSION_MAJOR = x;
static const unsigned VERSION_MINOR = y;
static const unsigned VERSION_REVISION = z;
This allows users easily check the version number:
I would recommend though that:
Any feature you add/remove/deprecate in your library should not require the users to test the version numerically, but rather you should add a #define and/or a method that specifies whether this option is on, off or optional, e.g:
#define AWESOME_LIBRARY_SUPPORTS_CACHING
-- OR/AND --
static bool isCachingSupported()
Any code you include in your library should be wrapped using a proper namespace to make sure that there are no naming collisions, since VERSION_MAJOR is a very general name.
You follow proper versioning conventions such as these and these.
Upvotes: 8