Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Automatically increment a build number
Forum Update on Monday, May 27th 2025

[SOLVED] Automatically increment a build number

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 8.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yanbellavance
    wrote on 17 Jun 2011, 20:43 last edited by
    #1

    I need to display the version of the software I am building. It will have the following nomenclature: majorVersion.MinorVersion.BuildNumber

    Any ideas on how I can increment a build number each time I build and how I can access this value from the program at run time?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on 18 Jun 2011, 08:13 last edited by
      #2

      you can have a look at this gitorious project: "auto incr build nr":https://www.gitorious.org/giesbert-s-software/autoincreasebuildnr and at "this":https://www.gitorious.org/giesbert-s-software/giesbert-s-world-clock/blobs/master/GiWorldClock.pro pro file, the tool is used there.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        silver47
        wrote on 20 Jun 2011, 06:52 last edited by
        #3

        I created my own program, which increase build number in main.cpp file. Build number has such format:
        @01 #define BUILDCOUNTER 825@
        I added a new build step in Project Options, which increase number after successful build.

        sorry for my english :(

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          yanbellavance
          wrote on 21 Jul 2011, 17:07 last edited by
          #4

          I ended up adding these lines to the .pro file:

          QMAKE_EXTRA_TARGETS += buildNo
          buildNo.commands = ./buildNoScript
          PRE_TARGETDEPS += buildNo # adding this removes the necessity to use .target

          Then I made a simple script called buildNoScript that calls a small program that updates build info in a file (it reads the build no from that file first then increments it and writes it back).

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved