Search code examples
qtqt-creator

Why Qt .pro files add source according to different platform doesn't work?


I want to configure a Qt.pro file for my project, I write my pro file like this:

unix {
SOURCES += a.cpp
}

win32 {
SOURCES += b.cpp
}

but a.cpp and b.cpp both included in qtcreator when I am in Windows, I look some explain is same as mine, see https://doc.qt.io/qt-5/qmake-language.html, I dont't known where is wrong? What is right to configure? my Qt version is 5.12.0


Solution

  • After my testing, this method is correct. Although a.cpp and b.cpp will be displayed in qtcreator at the same time, the MakeFile generated by qmake will not contain other platforms.