qmake conditional expressin, strange behaviour
Hello,
I am trying to write a conditional expression on my .pro file:
Code:
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...
Re: qmake conditional expressin, strange behaviour
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.
Re: qmake conditional expressin, strange behaviour
Hmm ok , thanks. Is there a way to hide the source tree conditionally?
Re: qmake conditional expressin, strange behaviour
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,
_
Re: qmake conditional expressin, strange behaviour
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:
Code:
DEFINES += MIKRODIAGRAM_EDITOR
and in the other one i have:
Code:
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:
Code:
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?