Custom build step for subprojects
I have a Subdirs Project, where there are 2 subprojects: MyLib (static C++ library project), MyLibTest (console app that uses MyLib; depends on MyLib).
I'd like to add custom pre-build steps that will automatically update the version file for modified projects.
The idea is that:
- if I modify the library, qmake will rebuild both MyLib and MyLibTest (depends on MyLib); both pre-build steps are executed; both version files will be updated.
- if I modify MyLibTest only, qmake will rebuild MyLibTest only; only MyLibTest pre-build step will run; only MyLibTest version file will be updated.
Looks like pre-build steps will run on whole Subdirs Project, so I can't do such thing.
Any hints about how I can do this?
Something's not clear, are you changing the version number of your library/application somewhere ?
@SGaist Well, as an example, I have a version.h file in both projects, with some defines that will be updated by an external tool. Something like
// version.h #define MAJOR_VERSION 1 #define MINOR_VERSION 2 #define BUILD_VERSION 123
The custom build step will call the external tool so that -before- running qmake BUILD_VERSION will be updated.
Why not use the VERSION variable in your .pro file ?
@SGaist Because I didn't know about it :) I'll made some test and look how it behave in both Windows and Linux.
BTW, the question is still open. How to update VERSION on every build?
Modifying the .pro file from the outside is not the correct idea. Since you only want to increment the build number you can mix both. VERSION from the pro file and build number generator that you can take inspiration from here