conditional includes in pro file
Hi,
My application has been written in such a manner that a stripped back 'lite' version can be compiled simply by not including the extra .h and .cpp files.
As far as I understand it this can be achieved in the .pro file like so:
Code:
CONFIG += full_version
SOURCES += core.cpp
HEADERS += core.h
full_version {
SOURCES += extra.cpp
HEADERS += extra.h
.....
}
The first time I compiled and ran this I got the full application in the exe. However if I make a change to the pro file, say, comment out the Config line, effectively asking for a 'lite' version I still get the full application. I thought possibly something was getting cached somewhere so I deleted the makefile, makefile.debug, makefile.release and everything in the debug and release folders, cleaned the project, ran qmake and built the project again. But I still got the full application. I repeated this a couple of times and on the last time I got my lite version. So I uncommented the config line again and now cannot get the full version back!
I believe the code is right in the .pro file but am I missing something when making changes to it?
Thanks, C.
Re: conditional includes in pro file
Here is a simple way to have conditional .pro file options:
Code:
// *.pro
contains(opt,x) {
SOURCES += x_file.cpp
....
} else {
SOURCES += no_x_file.cpp
...
}
When building your project, you can simply activate the "x" option by using qmake parameter:
Code:
// this will cause x_file.cpp to be compiled
qmake opt=x
// this will skip x_file.cpp and add no_x_file.cpp
qmake
// or
qmake opt=<anything but x>