Hastur
Hastur

Reputation: 2818

How to have an auto incrementing build version number (KDevelop)?

How to have an auto incrementing build version number in KDevelop?

I would like to set up a semi-automatic versioning for my local projects in .

Something like:

int MajorVersion = 1;  // this manual 
int MinorVersion = 2;  // this manual
int Revision = 42;     // this automatically increased each time I compile

When I compile, it would auto-increment just the Revision field.

Is this feature hidden somewhere in the settings and are those value maybe accessible from the system (mainly Linux, but all in general) or have they to be user implemented?

Note that I'm searching for solution inside , or in case not yet allowed for a simple method usable from commandline compiling and then importable in KDevelop.
I'm not searching solution for VisualStudio, as many answers offer from some similar questions [1],[2]....

Upvotes: 0

Views: 2875

Answers (1)

arrowd
arrowd

Reputation: 34401

This has little to do with IDE you are using. It is rather buildsystem thing. If you are using CMake, I imagine something like this:

if(NOT BUILD_REVISION)
  set(BUILD_REVISION 0 CACHE STRING "")
else()
  math(EXPR BUILD_REVISION "${BUILD_REVISION} + 1")
endif()

add_definitions(-DBUILD_REVISION=${BUILD_REVISION})

And then in the code

int Revision = BUILD_REVISION;

Upvotes: 4

Related Questions