Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Exam question about qmake, just for advance users.

    Tools
    qmake subdirs c
    2
    6
    948
    Loading More Posts
    • 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.
    • B
      bnogal last edited by bnogal

      What projects will be included if your project file contains the next code:

      TEMPLATE = subdirs
      
      MODELS = $$files(models/*.pro,true)
       
      for(m, MODELS){
          MODEL= $$split(m, "/")
         count(MODEL, 3) {
             SUBDIRS += $$m
         }
      }
      

      A) All the projects recursively inside models
      B) All the projects inside each direct subfolder of folder models

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Do you mean you want to know what this should be doing because you got it as a question in an exam ?

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

        1 Reply Last reply Reply Quote 0
        • B
          bnogal last edited by

          not really, i found it writting the building code for one of my projects.

          I really cant find the logic.....

          The result is the (A)
          And for more fun, if you print SUBDIRS, it contains exactly the paths as i would be (B)
          if instead of:
          SUBDIRS += $$m

          i write:
          SUBDIRS += $$member(MODEL,0)/$$member(MODEL,1)/$$member(MODEL,2)

          it works.

          i must miss a basic about qmake or i must miss a basic about logic.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by SGaist

            It's because you are trying to get files that match the "models/*.pro" pattern which is not the same as retrieving files from a folder named models and its subfolders following the pattern "*.pro"

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

            1 Reply Last reply Reply Quote 0
            • B
              bnogal last edited by bnogal

              that is what i pretend with the $files, as i didnt find a better way.

              and what i pretend with the loop for, is to check which ones, splitting it by "/", give 3 parts:

              1. "model"
              2. folder
              3. files".pro"

              If i use:
              $$m,
              it adds to SUBDIRS the ones i want, but QtCreator is adding everything

              If i add:
              $$member(MODEL,0)/$$member(MODEL,1)/$$member(MODEL,2)

              it adds the sameones to SUBDIRS, but QtCreator detect almost just the ones in SUBDIRS (a couple more than shouldnt)

              As i realized, when try to build it, it seems to process only the correct ones... (the Makefile is correct!) so i believe there is a bug in QtCreator. Can be?

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                If you mean that Qt Creator shows all of your subdirs while only part of them are built then no, its not a bug (well I don't see it as a bug). AFAIK, Qt Creator shows the complete source tree

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

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post