I'm working on a cross-platform Qt application and the paths are different on Mac OS X and Windows. Since the project is on an external hard-drive, the drive letter also occasionally changes on Windows.
For that reason, I would like to refer to the project directory using a variable, preferably a built-in one. In particular, is there such a variable usable in:
$$PWD means the dir where the current file (. pro or . pri) is. It means the same in LIBS . I just used it like this in my project: LIBS += -L$$PWD/deps/android -lopenal.
You can edit existing environment variables or add, reset and unset new variables based on your project requirements. To globally change the system environment from the one in which Qt Creator is started, select Edit > Preferences > Environment > System, and then select Change in the Environment field.
In the Qt Creator application, choose menu File->Open File or Project, navigate to the project folder and choose the . pro file to open.
A .pro file is actually the project file used by qmake to build your application, library, or plugin. It contains all the information, such as links to the headers and source files, libraries required by the project, custom-build processes for different platforms/environments, and so on.
To complete, @Bill's answer, the way to refer to the source path in the Build Settings is to use %{sourceDir}
.
%{buildDir}
is also available.
Since I struggled a bit to find it, I'm adding it here.
In addition to %{sourceDir}
and %{buildDir}
, you could use %{CurrentDocument:Path}
, %{CurrentDocument:FilePath}
and %{CurrentProject:Path}
to refer to specific files and folders in the project directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With