Is there any reasonable way to get the value of the .pro's VERSION? Perhaps some way to make qmake output a header file for it? It seems a bit of a waste to have my version in two places.
Is there any reasonable way to get the value of the .pro's VERSION? Perhaps some way to make qmake output a header file for it? It seems a bit of a waste to have my version in two places.
add a define directive to your pro file :
And then use the _VERSION_ macro (or whatever you named it) inside your code.DEFINES += _VERSION_=${VERSION}
Current Qt projects : QCodeEdit, RotiDeCode
sdfisher (27th July 2007)
Huh. This doesn't seem to work with the Visual Studio generator. I get VERSION_NUMBER=${VERSION} (with ${VERSION} not expanded) as one of my defines.
Edit: DEFINES += VERSION_NUMBER="$${VERSION}" seems to have worked, though. Thanks for the nudge in the right direction.
Edit #2: Actually, that doesn't seem to work, either. It adds VERSION_NUMBER="1.2.0.1" to the defines, but that doesn't seem to actually work.
Last edited by sdfisher; 27th July 2007 at 23:21.
I'm afraid I never used VS integration so I can barely suggest anything more... The thing is that dependencies are probably not set properly (i.e. files using this macro won't be automatically scheduled for compilation every time the macro changes...) so you may need a "rebuild all" (or whatever it is called) to get the version number actually taken into account by your code...
Current Qt projects : QCodeEdit, RotiDeCode
I think it's just a limitation of VS (not the integration, but of VS itself). It's okay. I can use that technique on other platforms.
Well, I'd tend to think that it's actually a limitation of most, if not all, compilers... I'm willing to bet that no build system (may it be cmake, qmake, scons, ...) does such a smart dependency checking... Just rebuild all once you changed the version number or do a "dummy edit" in each file that rely on the version macro. Dummy edit means forcing the file to be saved, without really modifying it, which triggers dependency tracking of your build system, since most rely on time stamps and not file hash... It generally expands to typing a char then undo-ing the change and then saving...
Current Qt projects : QCodeEdit, RotiDeCode
sdfisher (30th August 2007)
Yes, that worked. Thank you so much. I'd completely given up.
Bookmarks