qmake

How to specify compiler flag to a single source file with qmake?

我们两清 提交于 2019-11-30 16:59:00
问题 While other source files use the default flags? Some of my source files need some extra C++ preprocessor defines. I use Qt 5. I only found QMAKE_CXXFLAGS is for global use in qmake projects. 回答1: This is what used to be done in theory for GUI painting in the Qt source itself: SOURCES_NOOPTIMIZE = somefile.cpp nooptimize.name = nooptimize nooptimize.input = SOURCES_NOOPTIMIZE nooptimize.dependency_type = TYPE_C nooptimize.variable_out = OBJECTS nooptimize.output = ${QMAKE_VAR_OBJECTS_DIR}$

Conditionally disable warnings with qmake/gcc?

南楼画角 提交于 2019-11-30 14:21:32
I am involved with a software project written in Qt and built with qmake and gcc on Linux. We have to link to a third-party library that is of fairly low quality and spews tons of warnings. I would like to use -W -Wall on our source code, but pass -w to the nasty third-party library to keep the console free of noise and clutter so we can focus on our code quality. In qmake, is there a way to conditionally add CFLAGS/CXXFLAGS to certain files and libraries? Jonathan, I think the problem is where your source files are including header files from 3rd party libraries, and you want to switch off

In Linux how to add a build step in Qt Creator that uses su privileges without getting the wrong password attempts on builds?

馋奶兔 提交于 2019-11-30 14:12:37
My goal is to successfully link a folder to /opt/ directory- which needs to be run with sudo. I have tried this: system(sudo ln -s $$OUT_PWD/xampp /opt/lampp):message("You should manually link LAMPP") But building from qt-creator it does not prompt for sudo password, therefore I couldn't get it to link the folder. I got the "wrong password attempts..." error in the Compiler Output. Then I tried these with build steps: make sudo make install to see if it would prompt me there, but it failed on make install step with the same error, which is this in detail: 00:31:20: Starting: "/usr/bin/sudo"

How to add pre-build step in qmake/qtcreator?

 ̄綄美尐妖づ 提交于 2019-11-30 13:04:49
问题 I want the compiled application to have the commit number, source files checksums and other things to be available during the compilation. In plain Makefiles I do like this: prog: VERSION source.c gcc -DVERSION=\"$(shell cat VERSION)\" source.c -o prog VERSION: .git git describe > VERSION How to use something similar with qmake? 回答1: If you were to pass the version information as an included file (let's say "version.h") instead of a #define, then you could add the following to your qmake file

How to check the selected version of Qt in a .pro file?

为君一笑 提交于 2019-11-30 12:36:56
问题 I have multiple versions of Qt installed, and I need to compile my project with all of them. Using a pro file, I could not find in the documentation how to do a conditional compilation. Ideally, this is what I would like to do: QT_VERSION = 5 # this can be 4, set manually if(QT_VERSION == 5) { QT += widgets } if(QT_VERSION == 4) { QT += gui } Naturally, the if() command does not exist in pro files. Is there a better way to do the same thing? 回答1: You can use conditional functions and scopes

cmake not working, could not exec qmake

时光毁灭记忆、已成空白 提交于 2019-11-30 11:30:24
问题 I am using Ubuntu 14.04. I'm trying to install a program which requires cmake. When I run cmake src/ I get: qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory What am I doing wrong? 回答1: Does the trick: sudo apt-get install qt4-qmake You do not need to install half a gigabyte of qt sdk! 回答2: I read on another post that the problem has something to do with CMake not being able to find Qt4 qmake. However in my case, it was simply a matter of not having

qMake: How exactly does qmake interpret the “CONFIG(debug, debug|release)” syntax

不打扰是莪最后的温柔 提交于 2019-11-30 10:25:40
问题 I read though HERE, yet I still don't understand the syntax of the qmake CONFIG variable. for example, if I have the following CONFIG settings in my .pro file : CONFIG(debug, debug|release) { message("debug mode") }else { message("release mode") } then, when running qmake , the following will be displayed in the Compile Output in Qt-Creator: Project MESSAGE: debug mode Project MESSAGE: debug mode Project MESSAGE: release mode knowing that I am building my project in a "debug mode" , then my

Is there a possibility to pass includes via -isystem when using qmake

大憨熊 提交于 2019-11-30 09:31:09
I use qmake as a makefile builder and want to stick to it. Further I would like to use "gcc -Wall -Werror -Wundef -Wextra" to get robust code. I'm thinking about "-pedantic" but that's further up the road. My main problem at the moment are the tons of warnings generated by libraries like boost, parts of qt and the like. At the moment I use pragmas whenever I include warning-generating headers #pragma GCC diagnostic ignored "-Wall" #include <QtGui> ... #include <QWidget> #pragma GCC diagnostic error "-Wall" This is far from cute, rather tedious and cumbersome especially as other programmers

Add opencv library to every qt project

本小妞迷上赌 提交于 2019-11-30 09:25:03
问题 suppose that we want to link OpenCV library with Qt ,in common, we add INCLUDEPATH and LIBS in qmake(.pro file) but if you are a machine vision engineer then most of your projects have to include OpenCV library, so is there any way to add opencv library in time of creating project. I use below command to add OpenCV library for my projects every time. INCLUDEPATH += -I/usr/local/include/opencv LIBS += -L/usr/local/lib -lopencv_stitching -lopencv_superres ...and another libraries my OS is

How to add external libraries to qt4 application c++

╄→гoц情女王★ 提交于 2019-11-30 08:56:06
what is the best way to add additional compiled libraries to my qt project ? For example boost or poco libs ? Thanks :) Sebastian Dusza If you're using the GCC compiler add something like this to the .pro file: For Boost: INCLUDEPATH += d:/Biblioteki/C++/boost/boost_1_44_0a LIBPATH += d:/Biblioteki/C++/boost/boost_1_44_0a/stage/lib LIBS += -lboost_system-mgw44-mt-d-1_44 LIBS += -lboost_filesystem-mgw44-mt-d-1_44 LIBS += -lboost_date_time-mgw44-mt-d-1_44 For Poco: INCLUDEPATH += d:/Biblioteki/C++/Poco/poco-1.3.6p2-mingw-qt2/include LIBPATH += d:/Biblioteki/C++/Poco/poco-1.3.6p2-mingw-qt2/lib