Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] qmake Detect enviroment variable
Forum Updated to NodeBB v4.3 + New Features

[solved] qmake Detect enviroment variable

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.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.
  • rootshellR Offline
    rootshellR Offline
    rootshell
    wrote on last edited by
    #1

    Hello,

    Trying to write some code that reads a environment variable and adds some defines. not quite sure what I am doing wrong here:

    In the project file:
    equals($$(XDG_CURRENT_DESKTOP),"Unity"){
    DEFINES+= ISUNITY
    }
    contains($$(XDG_CURRENT_DESKTOP),"Unity"){
    DEFINES+= ISUNITY
    }

    in the code file:
    #ifdef ISUNITY
    // <-- this should run on Ubuntu / Linux
    #else
    // <-- It is always running this code, even when the environment variable is in place and should run the lines above
    #endif

    Certifications: CISSP, MCITP, MCSE, MCSA, BA, AA, AG, CST, CNST, Linux+, Security+, Server+, Network+, A+, iNet+

    Languages: C++, C#, VB, Python, Java

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

      Hi,

      equals takes a variable name so you might have to do it in two steps

      @
      CURRENT_DESKTOP = $$(XDG_CURRENT_DESTKOP)
      equals(CURRENT_DESTKOP, "Unity") {
      DEFINES += IS_UNITY
      }
      @

      same applies for contains.

      Hope it helps

      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
      0
      • rootshellR Offline
        rootshellR Offline
        rootshell
        wrote on last edited by
        #3

        Awesome thanks!

        Certifications: CISSP, MCITP, MCSE, MCSA, BA, AA, AG, CST, CNST, Linux+, Security+, Server+, Network+, A+, iNet+

        Languages: C++, C#, VB, Python, Java

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

          You're welcome !

          Since you have it working as you want now, please also update the thread title prepending [solved] so other forum users may know a solution has been found :)

          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
          0

          • Login

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