aviit
aviit

Reputation: 2109

Qt, qmake, pro file: Add compiler name to target name

I want to add the Qt version and compiler version to the target in .pro file like this:

msvc=$$basename(QMAKESPEC)
TARGET = Appname_Qt$${QT_VERSION}_$$msvc
message($$msvc)
message($$TARGET)

the result (message output) is:

Project MESSAGE: win32-msvc2008
Project MESSAGE: Appname_Qt4.7.1_win32-msvc2008

but the target output (file name) is:

Appname_Qt4.7.1_

the compiler name (version) was missed. How can I fix this?
Thank you so much!

//---- update --------- I tried with:

msvc=$$basename(QMAKESPEC)
msvcx=abcd
TARGET = Appname_Qt$${QT_VERSION}_$$msvcx
message($$msvc)
message($$TARGET)

and the target output (file name) is:

Appname_Qt4.7.1_abcd

(correct)

Upvotes: 4

Views: 1854

Answers (1)

You can't do that: by the time qmake runs, the compiler and Qt version are already fixed: they are the ones used to build the qmake in question.

The compiler and Qt version are determined at the time Qt is built. You select what Qt version/compiler combo to use by running the correct qmake executable.

Suppose you had VS 2012 and VS 2015, and Qt 4.8 and 5.5 installed, in following combinations:

  1. VS2012 + Qt 4.8
  2. VS2012 + Qt 5.5
  3. VS2015 + Qt 5.5

You'd have a qmake.exe in each of the builds. Each of them will generate a makefile that uses the proper compiler and Qt version. Additionally, you must start qmake in the environment where the given compiler is configured to be in the path: you have to run vcvars before running qmake. Qt Creator runs vcvars automatically for you each time before starting qmake or nmake/jom.

Upvotes: 1

Related Questions