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. Using "build settings" (configuration? target?) to set DEFINEs doesn't work?

Using "build settings" (configuration? target?) to set DEFINEs doesn't work?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
4 Posts 2 Posters 1.2k 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.
  • D Offline
    D Offline
    davecotter
    wrote on 6 Aug 2017, 00:20 last edited by
    #1

    in my build settings i have this:
    0_1501978635759_Screen Shot 2017-08-05 at 5.12.54 PM.png

    see how i've defined "TARGET" to be the name of the build setting?

    so then in my pro file i have this:
    0_1501978673786_Screen Shot 2017-08-05 at 5.15.16 PM.png

    see how it shows a "message" of the $${TARGET}? that WORKS when i run qmake (it shows correct build setting / target).
    however look a little further down, i want to set a DEFINE based on whether the $$TARGET has the word "Pro" or "2" in it. this is NOT working. see:
    0_1501978785612_Screen Shot 2017-08-05 at 5.15.22 PM.png

    Why doesn't this work? i tried with/without the $$ in the "contains()" call.

    aside: why is the pro file parsed THREE times?

    K 1 Reply Last reply 6 Aug 2017, 09:50
    0
    • D Offline
      D Offline
      davecotter
      wrote on 6 Aug 2017, 15:55 last edited by
      #4

      okay so "contains" is not a substring containment test. the test must be for the entire text of the variable. so this worked:

      if (contains(TARGET, "kJams Lite Debug") | contains(TARGET, "kJams Lite")) {
      	message("KJAMS_PRO NOT set :(")
      } else {
      	message("KJAMS_PRO SET! :)")
      	DEFINES += KJAMS_PRO
      }
      
      1 Reply Last reply
      1
      • D davecotter
        6 Aug 2017, 00:20

        in my build settings i have this:
        0_1501978635759_Screen Shot 2017-08-05 at 5.12.54 PM.png

        see how i've defined "TARGET" to be the name of the build setting?

        so then in my pro file i have this:
        0_1501978673786_Screen Shot 2017-08-05 at 5.15.16 PM.png

        see how it shows a "message" of the $${TARGET}? that WORKS when i run qmake (it shows correct build setting / target).
        however look a little further down, i want to set a DEFINE based on whether the $$TARGET has the word "Pro" or "2" in it. this is NOT working. see:
        0_1501978785612_Screen Shot 2017-08-05 at 5.15.22 PM.png

        Why doesn't this work? i tried with/without the $$ in the "contains()" call.

        aside: why is the pro file parsed THREE times?

        K Offline
        K Offline
        koahnig
        wrote on 6 Aug 2017, 09:50 last edited by
        #2

        @davecotter

        Does the '|' work there?
        You may need spaces around the sign.
        Did you try with Pro respectively 2 alone?

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • D Offline
          D Offline
          davecotter
          wrote on 6 Aug 2017, 15:38 last edited by
          #3

          you can use regex in that spot, so '|' without spaces is fine. but yes i tried just Pro or just 2, same problem.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            davecotter
            wrote on 6 Aug 2017, 15:55 last edited by
            #4

            okay so "contains" is not a substring containment test. the test must be for the entire text of the variable. so this worked:

            if (contains(TARGET, "kJams Lite Debug") | contains(TARGET, "kJams Lite")) {
            	message("KJAMS_PRO NOT set :(")
            } else {
            	message("KJAMS_PRO SET! :)")
            	DEFINES += KJAMS_PRO
            }
            
            1 Reply Last reply
            1

            4/4

            6 Aug 2017, 15:55

            • Login

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