[Interest] QMake contains and include

Jérôme Godbout godboutj at amotus.ca
Wed May 20 17:26:59 CEST 2020


Sorry for the noise, but I did found a way simpler example to test this:

if(false){
  message("Pass here")
  include("myfile.pri")
}

myfile.pri is always included no matter what, but the message is not printed! this is really counter intuitive. Any way to make a conditional include?!?


From: Interest <interest-bounces at qt-project.org> On Behalf Of Jérôme Godbout
Sent: May 20, 2020 11:17 AM
To: interest at qt-project.org
Subject: [Interest] QMake contains and include

Hi,
QMAKE question: anybody manage to use an include inside a contains(){} into QMake? the include is processed no matter what!?!
message("list: '$$AMOTUS_SUBREPOS_OPTIONAL_NAMES' ")
contains(AMOTUS_SUBREPOS_OPTIONAL_NAMES, i18n){
    message("Using i18n...")
    HEADERS += $$AMOTUS_Qt_PATH/i18n.h
    SOURCES += $$AMOTUS_Qt_PATH/i18n.cpp
    include(i18n.pri)
}contains(AMOTUS_SUBREPOS_OPTIONAL_NAMES, Amotus_Qt_Network){
    message("Using Amotus_Qt_Network...")
    include(Amotus_Qt_Network.pri)
}
If I put AMOTUS_SUBREPOS_OPTIONAL_NAMES = i18n
The message print:
Project MESSAGE: list: 'i18n'
Project MESSAGE: Using i18n...
The message is correct. But I get both the i18n.pri and the Amotus_Qt_Network.pri include anyway!? if I remove the i18n entry from the variable AMOTUS_SUBREPOS_OPTIONAL_NAMES =
I get the following:
Project MESSAGE: list: ''
The include for i18n.pri and Amotus_Qt_Network.pri are still included, but the i18n.h and i18n.cpp are grey out which seem to work for HEADERS and SOURCES but not include!?! is include special or parsed without any consideration of the scope?! I did try to close QtCreator and reopen without luck (using QtCreator 4.12.0 on Mac OS)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200520/554543e7/attachment.html>


More information about the Interest mailing list