PDA

View Full Version : qMake Question



yagabey
6th July 2014, 04:16
Hi,

I am writing two different Qt creator plugin applications. Some of their dependencies(plugins) are common. So i am trying to switch the included plugins.

For first application I renamed qtcreator.pro to app1.pro and th second application to app2.pro.

In the first .pro file Ive added " CONFIG += BUILD_FOR_APP1 " , and for the second .pro file I ve added " CONFIG += BUILD_FOR_APP2 " on top of the pro file.

To check the configuration setting; in qtcreator.pri I wrote:


for(p, CONFIG) {
message($${p})
}

In debug output I can see that my BUILD_FOR_APPX configuration is active, no poblem. And also


BUILD_FOR_APPX{
message(APPX Plugin activated)
}

prints correctly to output pane.

But when i run the same qmake script in plugins.pro, i see that no such configuration exists; although plugins.pro includes qtcreator.pri . So i cannot select the right plugins according to the configuration.

What is the problem here. How can I make "BUILD_FOR_APPX configuration" global to all project including sub projects?

Thanks in advance,
Yigit

anda_skoa
6th July 2014, 13:05
But when i run the same qmake script in plugins.pro, i see that no such configuration exists; although plugins.pro includes qtcreator.pri

Does it include one of the .pro files which set the variables?

Cheers,
_

yagabey
6th July 2014, 16:07
The variables are set in app1.pro or app2.pro. "plugins.pro" does not include these pro files but it includes "qtcreator.pri"
. Actually I am a bit confused about the qMake structure. The above script :


SCADA_EDITOR = 0

BUILD_FOR_SCADAEDITOR {
SCADA_EDITOR=1
message(ScadaEditor Plugin activated)
}

isEqual(SCADA_EDITOR,0) {
DEFINES += HELLO_WORLD_TEST
}else {
DEFINES += HELLO_MOON_TEST
}

for(p, DEFINES) {
message($${p})
}

print s that:


Project MESSAGE: ScadaEditor Plugin activated and


Project MESSAGE: HELLO_WORLD_TEST
Project MESSAGE: UNICODE
Project MESSAGE: IDE_LIBRARY_BASENAME=\"lib\"
Project MESSAGE: QT_CREATOR
Project MESSAGE: QT_NO_CAST_TO_ASCII
Project MESSAGE: QT_NO_CAST_FROM_ASCII

How can both "SCADA_EDITOR=1" and "SCADA_EDITOR=0" be valid. Whats that?

anda_skoa
7th July 2014, 10:19
The variables are set in app1.pro or app2.pro. "plugins.pro" does not include these pro files but it includes "qtcreator.pri"

From what you've written earlier the variable is either set in app1.pro or app2.pro, not in qtcreator.pri
If plugin.pro does not include either, how would it get the value?

Lets look at the the same situation in C++


// app1.h
#define SOMEDEFINE 1




// app2.h
#define SOMEDEFINE 0




// common.h
#ifdef SOMEDEFINE
#else
#endif




// plugin.h
#include "common.h"


plugin.h does neither include app1.h nor app2.h, so it has not way of seeing the define, right?



isEqual(SCADA_EDITOR,0) {
DEFINES += HELLO_WORLD_TEST
}else {
DEFINES += HELLO_MOON_TEST
}

Hmm, maybe isEqual($$SCADA_EDITOR,0)

Cheers,
_

yagabey
7th July 2014, 12:57
Ok , I agree with you about including headers issue. But is that also valid for qmake scripts? qtcreator.pri also does not include app1.pro or app2.pro. But these pro files include qtcreator.pri. qtcreator.pri can reach CONFIG definitions of app1.pro or app2.pro in this case. How can this be possible?

I will try "isEqual($$SCADA_EDITOR,0)" when i go back to home.

anda_skoa
7th July 2014, 14:38
Ok , I agree with you about including headers issue. But is that also valid for qmake scripts?

There is no indication that qmake has a different meaning of the concept of includes.



But these pro files include qtcreator.pri. qtcreator.pri can reach CONFIG definitions of app1.pro or app2.pro in this case. How can this be possible?

The code of qtcreator.pri is included into the file that includes it. In other words it becomes part of that file.
Just like when including a header, no?

Cheers,
_

yagabey
7th July 2014, 14:53
When i include "yourfile.h" into "myfile.cpp" I expect to reach "yourfile.h" 's definitions and methods from "myfile.cpp" ; but "yourfile.h" cant reach "myfile.cpp" ; isnt that the situation here? Or i am misunderstanding something...:confused:

anda_skoa
7th July 2014, 19:35
When i include "yourfile.h" into "myfile.cpp" I expect to reach "yourfile.h" 's definitions and methods from "myfile.cpp" ; but "yourfile.h" cant reach "myfile.cpp" ; isnt that the situation here? Or i am misunderstanding something...:confused:

Yes.
Have a look at the example in comment #4 again: http://www.qtcentre.org/threads/59692-qMake-Question?p=264861#post264861
The include instruction is replaced by the contents of the file.

Cheers,
_

yagabey
7th July 2014, 21:40
:) Ok Dear anda, i know it is replaced. But it looks a bit different in our case. Anyway let me not extend the thread further... Let me simplify my question then:

That is our qtcreator source tree :
https://qt.gitorious.org/qt-creator/qt-creator/source/0016e385ab944ba926c37f7bba87a7634eb47f1f:

that is the plugins.pro:
https://qt.gitorious.org/qt-creator/qt-creator/source/0016e385ab944ba926c37f7bba87a7634eb47f1f:src/plugins/plugins.pro

And qtcreator.pro:
https://qt.gitorious.org/qt-creator/qt-creator/source/0016e385ab944ba926c37f7bba87a7634eb47f1f:qtcreator .pro

Now i want to enable or disable some of the plugins in source tree by adding some configs or definitions to "qtcreator.pro".

How can i do that?

yagabey
10th July 2014, 09:56
Anyway.. I solved the issue by creating two unique projects and pulling the common parts by "svn externals" from svn repo. Everything seems ok for now. Thanks...