[Interest] QMake contains and include

Jérôme Godbout godboutj at amotus.ca
Thu May 21 15:31:30 CEST 2020


Thanks Thiago, it clear up. It does make more sense to me now.

My use case is my projects use a subrepository that have a core code mandatory and some optional parts. Many projects use that subrepos and inlclude or not the optional part based on the application need. It look like this:

MyApp1.pro
	MySubreposMandatory.pri
		MySubreposOption1.pri (included)
		MySubreposOption2.pri (not inlcuded)

MyApp2.pro
	MySubreposMandatory.pri
		MySubreposOption1.pri (included)
		MySubreposOption2.pri (inlcuded)

This is a simpler use case but this is how we do reuse many code part between our applications with generic code. When I'm doing app2 it make sens to edit the 	Option2, but when I do work in app1 I do not use the option2, I won't edit it. It ain't that bad, I was more confuse about that behavior. 

This is only my own opinion on the behavior:

Pro:
-I can see the available options project that I can include in my applications
-Search also fetch code from unused parts (replace API less chance to forget a code into optional part)

Cons:
-Clutter the UI with unsued parts and confuse my junior dev about what is used into the projects. We have to open the module and look if the source is grey out or not to known if that module is used into the application or look directly into the .pro
-Search also fetch code from unused parts (unwanted used code into application)

I do something like this into my app to easily add or remove stuff from it:

////////////////////
// MyApp.pro
AMOTUS_SUBREPOS_NAMES = Amotus_CPP Amotus_Qt Amotus_Qml Amotus_Style
AMOTUS_SUBREPOS_OPTIONAL_NAMES = i18n Amotus_Qt_FileSystem Amotus_Qt_OAuth Amotus_Qt_Network Amotus_Qt_Bluetooth Amotus_Qt_GUI 

for(a, AMOTUS_SUBREPOS_NAMES){
    !include($${AMOTUS_SUBREPOS_PATH}/$${a}/pri/$${a}.pri){
        error(Cannot find the sub repos $${AMOTUS_SUBREPOS_PATH}/$${a}/pri/$${a}.pri)
    }
}

////////////////////
// Amotus_Qt.pri
contains(AMOTUS_SUBREPOS_OPTIONAL_NAMES, i18n){
    include(i18n.pri)
    HEADERS += $$AMOTUS_Qt_PATH/i18n.h
    SOURCES += $$AMOTUS_Qt_PATH/i18n.cpp
}
contains(AMOTUS_SUBREPOS_OPTIONAL_NAMES, Amotus_Qt_FileSystem){
    include(Amotus_Qt_FileSystem.pri)
}
...

-----Original Message-----
From: Interest <interest-bounces at qt-project.org> On Behalf Of Thiago Macieira
Sent: May 20, 2020 9:44 PM
To: interest at qt-project.org
Subject: Re: [Interest] QMake contains and include

On Wednesday, 20 May 2020 10:39:50 PDT Jérôme Godbout wrote:
> If I may, why I want that in QtCreator exactly? what is the use case 
> for this? If my project doesn't use a part, why is it parsed at all? 
> What will happen if that unused .pri make a failure for something 
> missing? Will it failed to load the project and stop? let's say I have 
> an option that require an interaction with another subrepos, one 
> project might not need that part and not have it checkout, the .pri 
> that interact with it would not be include, how would QtCreator react to this?

Are those two source files not part of your project? If they are, then they should be included in the file listing. I assume you sometimes edit them.

The Qt Creator ProParser code has some different error recovery mechanisms than qmake. Obviously it's going to be non-fatal to interact with a repository that is missing. It will also not run $$system() and do some other things that qmake would.

--
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products



_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest


More information about the Interest mailing list