Solved using variables for paths in project file
-
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_NAME
and it's an environment variable use$${ENV_VAR_NAME}
. -
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?
Thanks, guys.
-
@mzimmers said in using variables for paths in project file:
when I want to use one as a concatenator,
You don't want to.
A backslash at the end-of-line in a
.pro
file is always line-continuation. But forward slashes may be translated in the generated Makefile and that's where the fun begins... -
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?
-
Hi @mzimmers,
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?
Also correct.
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.