qmake

Qt: *.pro vs *.pri

亡梦爱人 提交于 2019-11-27 11:52:05
What is the difference between *.pro and *.pri configuration files for qmake? What should go into a *.pro file and what should go into a *.pri file? A .pro file is what you would run QMake on. A .pri file is included by a .pro file. Other than that there is not much of a difference between the two. Example usage could be if you have different builds which need different options. You could put shared information in the .pro, while deferring the options to various .pri files. A bit more information, although admittedly not much more, can be found here . lpapp There is one main difference between

Building multiple targets in Qt / Qmake

放肆的年华 提交于 2019-11-27 10:49:39
问题 How could I specify multiple targets with different configurations in Qt? Is there a way to do it in one .pro file? For example, I would want to build the following 2 .pro files (without having to manually change the .pro file each time): targetA: QT += network TEMPLATE = app SOURCES += main.cpp \ mainwindow.cpp HEADERS += mainwindow.h FORMS += mainwindow.ui RESOURCES += resource.qrc TARGET = targetA DEFINES += PARAMA targetB: QT += network TEMPLATE = app SOURCES += main.cpp \ mainwindow.cpp

QMake - How to add and use a variable into the .pro file

[亡魂溺海] 提交于 2019-11-27 10:44:25
I have a qmake file generated by Qt creator. I am modifying it but I do not manage to understand how to create a variable. For example, I want to declare the library MYPATH as I did here: MYPATH = /lib/aaa/bbb unix:!macx:!symbian: LIBS += -L$(MYPATH) When I run qmake I find in the generated makefile LIBS = ....... -L$(MYPATH) ..... But the MYPATH variable is not declared anywhere. Does anyone know how to declare such a variable properly? jwernerny QMake uses its own syntax for variable references . VAR = foobar => Assign value to variable when qmake is run $$VAR => QMake variable's value at

Qmake project dependencies (linked libraries)

社会主义新天地 提交于 2019-11-27 09:06:00
问题 I have a project that links to a number of shared libraries. Lets say project A depends on projects B and C Ideally, I want to impose the following dependencies in my project file: Rebuild project A if either B or C has been rebuilt since last time project A was built Use the output for the relevant configuration (i.e. if building project A in debug mode, then use the debug versions of the libs for project B and C) Does anyone know how I may explicitly express such dependencies in my project

How can I use C++14 features when building qmake projects?

岁酱吖の 提交于 2019-11-27 09:02:25
I'm currently using C++11 features in my Qt applications. However, I'd like to use some of the new C++14 features in my applications. To enable C++11 in a Qt application, one only needs to add one line in the qmake project file, namely: CONFIG += c++11 or this for earlier versions: QMAKE_CXXFLAGS += -std=c++1y I already tried to do the same with C++14, but it didn't work. I changed the above mentioned line of the qmake project like this: CONFIG += c++14 or this for earlier versions: QMAKE_CXXFLAGS += -std=c++1y After that, lots of compilation errors, that did not exist before, appear when

Linker doesn't use a default runtime library when linking together libraries only (no objects)

*爱你&永不变心* 提交于 2019-11-27 08:49:01
问题 I want the users to be able to re-link my Qt-using application to their own build of Qt, without being forced to rebuild all of the sources. This could be used for LGPL compliance, for example. To do this, I need to provide object files for all of my sources. To make it easy, using qmake, I've partitioned the project internally into: A static library project that contains objects for all of the source files, including the file that has int main(int, char**) . An application project that links

How to execute shell command after compile finished from .pro in QT?

我只是一个虾纸丫 提交于 2019-11-27 08:19:43
What changes must I make to the .pro file if I want to execute chmod command, execute the output binary file, or do some other operations. Dariusz Scharsig I had a similar problem. I wanted a special tool (versioner) to run over the code every time the Makefile was executed. Here's the solution: (to be read in the Qmake Manual, Configuring qmake's Environment, Section: Customizing Makefile Output ) Create you own Makefile target. Specify the command etc. mytarget.target = .buildfile mytarget.commands = touch $$mytarget.target QMAKE_EXTRA_TARGETS += mytarget This way, you have an extra target

qmake pre-build step before ANY compilation

有些话、适合烂在心里 提交于 2019-11-27 07:50:29
There are several questions on SO regarding how to create a pre-build step for qmake , I can do that with this in my .pro file: versionTarget.target = ../VersionData/versioning.h versionTarget.depends = FORCE win32: versionTarget.commands = cd $$PWD; python.exe ./version_getter.py -p $$TARGET else: versionTarget.commands = cd $$PWD; python ./version_getter.py -p $$TARGET PRE_TARGETDEPS += ../VersionData/versioning.h QMAKE_EXTRA_TARGETS += versionTarget Now, the problem is that this approach is not a build step per se but just another build target, so if I have the -j flag configured for make

How to read file content into a qmake variable and pass it to the compiler?

≡放荡痞女 提交于 2019-11-27 07:21:42
问题 How to read file content into a variable in qmake project file? For example, I'd like to have the contents of KEY read from a file and pass it to the compiler: DEFINES += KEY=**some magic and filename here** 回答1: On all platforms, there's a built-in replace function $$cat : # set a qmake variable KEY = "$$cat(/path/to/the/file)" # propagate the variable to C/C++ DEFINES += "KEY=\"$$KEY\"" The effect of this line is the same as if you added the following line at the beginning of every

Linking libraries to a QT project using pkg-config output

狂风中的少年 提交于 2019-11-27 05:46:25
问题 This is a bit of a newbie question. I am trying to add the OpenCV libraries to a QT project. This question says the link flags are given by pkg-config --libs opencv If I paste the command line output into the project file like: LIBS += -L/usr/local/lib -lml -lcvaux -lhighgui -lcv -lcxcore then everything compiles fine, but now this isn't portable. How can I simply reference the output of the command? Update: Tried Ken Bloom's suggestion, but it won't compile. The actual generated compiler