[SOLVED] [QMake] How to conditionally compile code depending on debug/release
-
In a large C++/Qt/QMake/qtcreator project I would like to perform some tests, but only when I am compiling with the debug flag.
Is there a way to tell g++ that some small parts of the code have to be compiled only in debug mode ?
I have tried things like this but without success..
@
#ifdef DEBUG
cout << "We are in Debug" << endl;
#else
cout << "We are in Release" << endl;
#endif
@I guess I need to put the "DEBUG" flag somewhere in the QMake project, like:
@
CONFIG(release, debug|release) {
TARGET = ffsm
}
CONFIG(debug, debug|release) {
TARGET = ffsm_debug
}
@ -
Hi and welcome to devnet,
You can use
@#ifdef QT_DEBUG
// My debug related code
#else
// Release only code
#endif@ -
thank you, it works the expected way...
-
You're welcome !
A little side note since you want do tests, you might be interested by the QTest framework
Happy coding !