Solved using variables for paths in project file
Hi all -
I have a project that relies heavily on a third-party IDF. I have many entries in my .pro file pointing to subdirectories of this IDF, like so:
INCLUDEPATH += \ "C:\esp-idf-release-v3.2\components\bt\include" \ "C:\esp-idf-release-v3.2\components\bt\bluedroid\api\include\api" \ "C:\esp-idf-release-v3.2\components\coap\port\include" \ "C:\esp-idf-release-v3.2\components\console" \ "C:\esp-idf-release-v3.2\components\driver\include" \ "C:\esp-idf-release-v3.2\components\esp_adc_cal\include" \ "C:\esp-idf-release-v3.2\components\esp32\include" \ "C:\esp-idf-release-v3.2\components\esp_https_ota\include" \ ...
The root directory of this IDF changes, and I'd like to use a variable (Qt or Windows) to hold it, so my .pro file would look something like:
INCLUDEPATH += \ $IDF_PATH"\components\bt\include" \ ...
But I don't know the correct syntax. Couldn't find it on the QMake variables page. Can someone show me the light?
IDF_PATHan environment variable ?
It certainly could be, or I could create it within Qt. Either way is fine with me.
To get the content of a variable you should use:
$$VARIABLE_NAMEand it's an environment variable use
That much I understand. Now, how do I fit that prefix to the rest of the path? Meaning, something like this (but this doesn't work):
$$IDFPATH + "\components\bt\include"
INCLUDEPATH += $$IDFPATH/components/bt/include
You can (and should) use forward slash also on Windows. qmake will do the necessary conversions for you.
I'd say you must ;)
And a hint to @mzimmers: never end a line with a backslash or a slash - this will lead to problems sooner or later. I have had big problems already when doing something like:
INCLUDEPATH += $$IDFPATH/components/bt/include/as the last slash was converted to backslash and there to problems begun...
Yeah, I was just being lazy...I'd grabbed those paths from somewhere else and just plugged them in verbatim. Now corrected.
So, aha - if I can't end a line with a backslash, when I want to use one as a concatenator, should I move it to the start of the next line?
MYPATH = /usr/include MYOTHERPATH = $$MYPATH/mylib
If you need backslashes then you have to double them as you would in a classic C string. However, you really should use forward slashes.
@aha_1980 I misspoke - I didn't mean concatenator; I meant line continuator. I interpreted your earlier statement as saying a backslash shouldn't end a line, but I guess you meant when used as part of a Windows-style path?
you're right, the backslash is the line continuator for qmake.
but I guess you meant when used as part of a Windows-style path?
But what could be unexpected, is if you end a Unix-style path with '/', this will be converted to a backslash in the Makefile an can lead to fun there also.