This is entire pro
file:
message("This message should appeare only once!!!")
CONFIG += qt
SOURCES += src/main.cpp
I invoke qmake
in the following way:
set QMAKESPEC=win32-msvc2008
set QTDIR=c:\Qt\4.8.4_vs2008\
call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
call "%QTDIR%\bin\qmake.exe" -tp vc Server.pro
And I get following output:
Setting environment for using Microsoft Visual Studio 2008 x86 tools.
Project MESSAGE: This message should be appeared only once!!!
Project MESSAGE: This message should be appeared only once!!!
Project MESSAGE: This message should be appeared only once!!!
Why did the message print THREE times?
qmake provides a number of built-in functions to enable the contents of variables to be processed. The most commonly used function in simple project files is the include() function which takes a filename as an argument.
qmake was created by Trolltech (now The Qt Company). It is distributed and integrated with the Qt application framework, and automates the creation of moc (meta object compiler) and rcc (resource compiler) sources, which are used in Qt's meta-object system and in the integration of binary resources (e.g., pictures).
pro file is to list the source files that are involved in a project. Since qmake is used for building Qt and its associated tools, it knows Qt very well and can generate rules for invoking moc, uic, and rcc. As a result, the syntax is very concise and easy to learn.
Qt qmake Default "pro" file. If you start Qt Creator and select File -> New File or Project -> Application -> Qt Widgets application, Qt Creator will generate a project skeleton for you along with a "pro" file.
Actually, the condition "build_pass" is always true except the first time qmake parses your .pro file, so the following works:
!build_pass:message("This message should appear only once")
I made a helper function, which works fine in my project:
defineTest(print) {
!build_pass:message($$1)
}
print("This message should appear only once")
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