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.
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).
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.
Re: Environment variables and qmake
Have a look at qmake function reference. I guess you will find the answer contained in it :-)
Re: Environment variables and qmake
Code:
AMDAPPSDKROOT = $$(AMDAPPSDKROOT)
!isEmpty(AMDAPPSDKROOT) {
INC_DIRS = "$${AMDAPPSDKROOT}include"
}