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. [Solved] .pro file questions (custom variables, mkspecs and contains())

[Solved] .pro file questions (custom variables, mkspecs and contains())

Scheduled Pinned Locked Moved Qt Creator and other tools
4 Posts 2 Posters 4.2k Views 1 Watching
  • 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 Offline
    B Offline
    Bullub
    wrote on last edited by
    #1

    My environment is Ubuntu 12.04 LTS, with Qt Creator 2.5.2, 64 bits.

    I'm dealing with .pro file in a project, trying to figure how it works. I've found some inconsistences I'd like to ask about.

    CUSTOM VARIABLES AND CONTAINS

    If I write in .pro file
    @MYVAR = "Mommy";
    message($$MYVAR)
    contains( MYVAR , Mommy )
    {
    message("got Mommy")
    }
    contains( MYVAR, Daddy )
    {
    message("got Daddy")
    }
    @

    compiling gives me this output:
    @Project MESSAGE: Mommy;
    Project MESSAGE: got Mommy
    Project MESSAGE: got Daddy@

    "contains( MYVAR, Daddy )" is not working as expected (same with $$MYVAR)!! "contains( MYVAR, Daddy )" block should not be executed, but it does... ¿why?

    MKSPECS USAGE

    According to Qt documentation, we can use mkspecs variables to check compiling platform.

    well, if I put
    @linux-g++-64
    {
    message("Linux 64 bits with g++")
    }
    @

    Building complains with this error:
    @Parse Error ('linux-g++-64')
    error: [Makefile] Error 3@

    Why? I've check /usr/share/qt4/mkspecs folder and there is a folder called "linux-g++-64"...

    1 Reply Last reply
    0
    • C Offline
      C Offline
      code_fodder
      wrote on last edited by
      #2

      I believe you have a syntax error that may be the cause your issues:

      I am not on my code PC so I just took the first example I found on the internet to show you:
      @
      use_libs {
      LIBS += -lmylib1 -lmylib2
      } else {

      Stub out parts of the app by not including the libs.

      }
      @

      Note: the condition is followed immediatley by the braces "{" on the same line not on the line after (as you might do in c/c++). If I recall you must have the brace on the same line otherwise it is not part of the condition and all you end up with is seperate lines of code which all execute (as you have in your mommy/daddy example.

      I am fairly certain that will fix your first issue, it might fix the second if it is complaining about just calling "linux-g++-64" on its own.

      So you may end up with:
      @
      MYVAR = "Mommy";
      message($$MYVAR)
      contains( MYVAR , Mommy ) {
      message("got Mommy")
      }
      contains( MYVAR, Daddy ) {
      message("got Daddy")
      }
      @

      and

      @
      linux-g++-64 {
      message("Linux 64 bits with g++")
      }
      @

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bullub
        wrote on last edited by
        #3

        Yeah, man, you pointed in the right direction!! Now it works as expected.

        Final right codes are:

        @MYVAR = "Mommy"
        message($$MYVAR)
        contains( MYVAR , Mommy ){
        message("got Mommy")
        }
        contains( MYVAR, Daddy ){
        message("got Daddy")
        }@

        Notice A: MYVAR = "Mommy" with no ";" at end
        Notice B: "{" in same line as "contains( variable, value ) {"

        and

        @linux-g++-64 {
        message("Linux 64 bits with g++")
        }

        tru64-g++ {
        message("Hala")
        }

        linux-g++ {
        message("generic linux g++")
        }@

        Notice C: "{" in same line (again) as mkspec value
        Notice D: I expected "linux-g++-64" would be my mkspec, but looking carefully in Compile Output, I saw this: "-spec /usr/share/qt4/mkspecs/linux-g++" as qmake's argument. So, in this case my mkspec is "linux-g++".

        Thanks, Code_Fodder. Telepathycal beer for you!!

        1 Reply Last reply
        0
        • C Offline
          C Offline
          code_fodder
          wrote on last edited by
          #4

          bq. Thanks, Code_Fodder. Telepathycal beer for you!!

          lol.....thanks!

          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