I believe by operating system that you mean the target architecture you are compiling for. That's the context in which the .pro file operates, and it may or may not be the same architecture as the operating system of the host machine you are developing on.
You can specify a conditional expression in the .pro file based on the qmake spec that you are compiling with. For example, if you want to include some libraries only when you are compiling for an embedded Linux architecture, then you would put:
linux-oe-g++ {
LIBS += -lsomelib
HEADERS += SomeClass.h
SOURCES += SomeClass.cpp
}
These lines would only go into effect when linux-oe-g++
is used as the -spec argument for qmake. (This is set in the Qt Creator IDE by configuring the project to use a kit that has the platform specified in the "Qt makespec" field.)
A preprocessor directive like the following C++ code does depend on the operating system you are developing on:
#ifdef __linux__
#include "linux/mylinuxlib.h"
#endif
This conditional is environment-dependent and is true only if I am developing on a Linux OS. It does not depend on the target architecture I am compiling for.
qmake
tutorial shows you how: qt-project.org/doc/qt-4.8/qmake-tutorial.html – Jump