qmake is strange, it implements custom syntax and grammar. Don't search for any deep logic there. It will be superseded by CMake soon anyway.
 
About your issue, I looked it up on DuckDuckGo, and the first result is the discussion on StackOverflow which looks like it:
https://stackoverflow.com/questions/46078270/qmake-scope-syntax-with-contains-function
 
Hope that helps somehow~
 
20.05.2020, 18:29, "Jérôme Godbout" <godbo...@amotus.ca>:

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-boun...@qt-project.org> On Behalf Of Jérôme Godbout
Sent: May 20, 2020 11:17 AM
To: interest@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)

 

,

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

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

Reply via email to