PDA

View Full Version : Pre-processor-defines depending on makefile-targets ?



Comer352l
11th March 2009, 16:49
Hi,

I'm searching for a possibility to create pre-processor-defines depending on the called makefile target.
I'm currently using the usual solution for conditional compiling of debug code parts:


#ifdef DEBUG
...debug-code
#endif

At the moment, I set DEBUG in a separate header-file, which I have to include in all souces that contain such debug-sequences.
My idea/intention is to make this separate header-file obsolete. DEBUG should be set when I compile the software with "make debug" (only).

It's a qmake-project and I use CONFIG += debug_and_relase.

I know the DEFINES option, but don't know how to make it depending on the called make target. Does anyone know how to do that ?

Frank

jpujolf
11th March 2009, 17:29
Have you tried ?



debug:DEFINES += __MY_DEBUG_DEFINE__
release:DEFINES += __MY_RELEASE_DEFINE__

Comer352l
11th March 2009, 18:51
Thanks for your answer ! Yes, I already tried that but it doesn't work :(:
Becasue of CONFIG += debug_and_release, always both (__MY_DEBUG_DEFINE__ and __MY_RELEASE_DEFINE__) will be defined. It doesn't matter which makefile-target I call...

Comer352l
12th March 2009, 14:00
I finally solved it:



CONFIG(debug, debug|release) {
DEFINES = __MY_DEBUG_DEFINE__
} else {
DEFINES = __MY_RELEASE_DEFINE__
}


I still don't understand CONFIG(...) completely, documentation is really incomplete for stuff like this...

wysota
12th March 2009, 20:33
Have you seen the article in our wiki regarding Undocumented qmake features?