PDA

View Full Version : qmake conditional expressin, strange behaviour



yagabey
17th May 2014, 23:31
Hello,

I am trying to write a conditional expression on my .pro file:


DEFINES += MIKRODIAGRAM_EDITOR
contains(DEFINES, MIKRODIAGRAM_EDITOR) {
SUBDIRS += diagramEditor
warning(DiagramEditor Plugin activated)
}
else{
SUBDIRS += scadaEditor
warning(ScadaEditor Plugin activated)
}

On Qt Creator(3.1) output console , I see only "DiagramEditor Plugin activated" text as it should. But Qt Creator adds both "diagramEditor" and "scadaEditor" folders to the project tree. Is this a bug or something else?

Thanks in advance...

ChrisW67
18th May 2014, 04:57
Qt Creator shows both source directories in the project because both source directories are part of the project. That you choose to include one or the other at build time is not relevant to the process of editing the source of the project.

yagabey
18th May 2014, 09:00
Hmm ok , thanks. Is there a way to hide the source tree conditionally?

anda_skoa
18th May 2014, 11:26
Put the different parts into .pri files (project includes) and have two .pro files that include the things for each variant.

Then you open whatever variant you are working on.

Cheers,
_

yagabey
18th May 2014, 12:09
The project tree is a bit complicated. I dont want to make any changes on .pri files. I am trying to solve the problem with 2 different .pro files. In one of them i have:


DEFINES += MIKRODIAGRAM_EDITOR

and in the other one i have:


DEFINES += MIKROSCADA_EDITOR


The definition is not valid on the sub .pro and .pri files. The code below is in one of the sub .pro files:


contains(DEFINES, MIKRODIAGRAM_EDITOR) {
SUBDIRS += diagramEditor
warning(DiagramEditor Plugin activated)
}
else{
SUBDIRS += scadaEditor
warning(ScadaEditor Plugin activated)
}

always returns "ScadaEditor Plugin activated". Isn't the scope of DEFINES valid through all the project?