Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. qmake called from QtCreator: packagesExist and system always succeed

qmake called from QtCreator: packagesExist and system always succeed

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
6 Posts 3 Posters 496 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • letsfindawayL Offline
    letsfindawayL Offline
    letsfindaway
    wrote on last edited by letsfindaway
    #1

    Within a qmake file I try to make some configuration dependent on the existence of a package or the result of a command. But whatever I try: they always succeed, no matter what the result of the operation is. To reproduce, I just created the minimal pure C application and added these statements as follows:

    TEMPLATE = app
    CONFIG += console
    CONFIG -= app_bundle
    CONFIG -= qt
    
    SOURCES += \
            main.c
    
    system(false):message("Message1")
    packagesExist(doesnotexist):message("Message2")
    

    Both messages are printed, even if they should not. My platform:

    • openSUSE Leap 15.3
    • QMake version 3.1
    • running from QtCreator

    A similar problem was probably reported years ago, but without a solution: https://forum.qt.io/topic/62452/how-to-use-qmakes-packagesexists-function. What am I missing? What am I doing wrong? Or is anything wrong with my platform?

    Edit: I just found out that when I run qmake manually from the command line then it seems to work! So what might be wrong with my QtCreator setup?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Which version of Qt are you using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      letsfindawayL 1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ziller
        wrote on last edited by ziller
        #3

        @letsfindaway said in qmake: packagesExist and system always succeed:

        Both messages are printed

        I just found out that when I run qmake manually from the command line then it seems to work!

        Please be aware that Qt Creator does two different passes when reading .pro files: one "exact" pass, and one "inclusive" pass.
        The "exact" pass is used for the code model, and evaluates conditions.
        The "inclusive" pass is for the project tree, and basically ignores conditions. That is done so that if you e.g. have "win32:SOURCES+=foo_win.cpp" the file "foo_win.cpp" still appears in the project tree even if you are on Linux/macOS.

        So, the "reference" for if it works in qmake or not is the compile output when you compile your project.

        letsfindawayL 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          Which version of Qt are you using ?

          letsfindawayL Offline
          letsfindawayL Offline
          letsfindaway
          wrote on last edited by letsfindaway
          #4

          @SGaist Same behavior for the Qt 5.12 still used as standard on Leap 15.3 and Qt 6.2. Here the output of querying the version:

          > qmake-qt5 --version
          QMake version 3.1
          Using Qt version 5.12.7 in /usr/lib64
          
          > qmake6 --version
          QMake version 3.1
          Using Qt version 6.2.4 in /usr/lib64
          
          > qtcreator -version 
          
          Qt Creator 4.12.0 based on Qt 5.12.7
          
          1 Reply Last reply
          0
          • Z ziller

            @letsfindaway said in qmake: packagesExist and system always succeed:

            Both messages are printed

            I just found out that when I run qmake manually from the command line then it seems to work!

            Please be aware that Qt Creator does two different passes when reading .pro files: one "exact" pass, and one "inclusive" pass.
            The "exact" pass is used for the code model, and evaluates conditions.
            The "inclusive" pass is for the project tree, and basically ignores conditions. That is done so that if you e.g. have "win32:SOURCES+=foo_win.cpp" the file "foo_win.cpp" still appears in the project tree even if you are on Linux/macOS.

            So, the "reference" for if it works in qmake or not is the compile output when you compile your project.

            letsfindawayL Offline
            letsfindawayL Offline
            letsfindaway
            wrote on last edited by
            #5

            @ziller said in qmake: packagesExist and system always succeed:

            Please be aware that Qt Creator does two different passes when reading .pro files: one "exact" pass, and one "inclusive" pass.
            The "exact" pass is used for the code model, and evaluates conditions.
            The "inclusive" pass is for the project tree, and basically ignores conditions. That is done so that if you e.g. have "win32:SOURCES+=foo_win.cpp" the file "foo_win.cpp" still appears in the project tree even if you are on Linux/macOS.

            So, the "reference" for if it works in qmake or not is the compile output when you compile your project.

            I'm trying to use packagesExist for selecting a package and an optional other package. And always the first check succeeds, even if that package does not exist. The build fails if it is not the first checked package.

            The project file shown above is the minimal example to demonstrate the problem. Note that calling the $$system() function works, just the test functions system() and packagesExist() are returning the wrong (always good) result. The command given to the system() test function is never executed.

            1 Reply Last reply
            0
            • letsfindawayL Offline
              letsfindawayL Offline
              letsfindaway
              wrote on last edited by
              #6

              I just found this comment to a quite old bug report from 2014 which might be related: https://bugreports.qt.io/browse/QTCREATORBUG-11510?focusedCommentId=233279&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-233279

              Since we don't want to run arbitrary processes while parsing the project, the evaluator simply assumes that the process could be run successfully and thus packageExists returns true.

              However I do not understand that, and also don't know how to resolve the issue.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved