Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qmake processes my pro-file three times instead of one

Tags:

qt

qmake

vcproj

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?

like image 254
tmporaries Avatar asked Jun 28 '13 08:06

tmporaries


People also ask

What is qmake file?

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.

Is qmake a compiler?

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).

What is .pro file in Qt?

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.

Where is .pro file in Qt?

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.


1 Answers

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")
like image 155
ZeRemz Avatar answered Oct 26 '22 12:10

ZeRemz