Results 1 to 5 of 5

Thread: Environment variables and qmake

  1. #1
    Join Date
    Mar 2011
    Posts
    29
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Environment variables and qmake

    Is there a way to do a conditional compilation according to environment variables with qmake:

    I am trying to recreate the following:

    ifdef AMDAPPSDKROOT
    INC_DIRS = "$(AMDAPPSDKROOT)include"
    endif

    ifdev NVSDKCOMPUTE_ROOT
    INC_DIRS = "$(NVSDKCOMPUTE_ROOT)\OpenCL\common\inc"
    endif

    Also there is another problem

    Even though I have done this:
    INCLUDEPATH += "$NVSDKCOMPUTE_ROOT\OpenCL\common\inc"

    where NVSDKCOMPUTE_ROOT is "C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.2"

    Even though I use double quotes, the gcc gets the path as separate words. Actually that part \NVIDIA Corporation\ is OK but the next: NVIDIA GPU Computing SDK 4.2 gets split into five words and causes errors. Why don't the double quotes work? My workaround was to copy these files to a folder without white spaces for now. Is this a bug or a feature.

    I would like my project file to compile on 3-4 different configurations: Linux 32/64bit, Windows 7 32/64 bit with NVIDIA SDK or AMD SDK respectively depending on the available hardware.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Environment variables and qmake

    Double quotes do not quote the whole path while being sent to gcc, they just make qmake treat it as a single token instead of splitting it into a list. It's best to explicitly escape all spaces, as far as I remember qmake has a function to do that (consult qmake manual).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Posts
    29
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Environment variables and qmake

    Thanx! The function quote() did the trick. Although according to the documentation it is just a fancy way to put double quotes around a string.

    I still cannot figure out how to check if environment variables are defined.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Environment variables and qmake

    Have a look at qmake function reference. I guess you will find the answer contained in it :-)

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Environment variables and qmake

    Qt Code:
    1. AMDAPPSDKROOT = $$(AMDAPPSDKROOT)
    2. !isEmpty(AMDAPPSDKROOT) {
    3. INC_DIRS = "$${AMDAPPSDKROOT}include"
    4. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 25th February 2011, 15:08
  2. Replies: 0
    Last Post: 24th November 2010, 11:11
  3. Environment variables in project .includes?
    By Karmaflute in forum Qt Tools
    Replies: 4
    Last Post: 26th November 2009, 00:59
  4. Order of qmake variables
    By babu198649 in forum Newbie
    Replies: 3
    Last Post: 29th June 2008, 09:02
  5. Accessing Environment Variables
    By mhoover in forum Qt Programming
    Replies: 6
    Last Post: 21st September 2006, 15:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.