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

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 … Read more

Running a program/script from QMake

It looks like QMAKE_POST_LINK works well for this sort of thing. This seems to get the job done. my_batch_file.bat runs when nmake runs (rather than when qmake runs) and I don’t need to do anything funny with placeholder targets or files. It’s quite likely that I don’t need all of the items listed in ‘CONFIG’. … Read more

How to convert qmake to cmake?

QMake: The required libraries. QT += core QT -= gui QT += network CMake: only the add is necessary. An exclude (QT -= gui) is not required. find_package(Qt5Core REQUIRED) find_package(Qt5Network REQUIRED) QMake: Additional Compiler flags: CONFIG += c++11 CMake: Extend the list of compiler flags as required. set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=c++0x”) QMake: The source files SOURCES … Read more

Add a define to qmake WITH a value?

DEFINES += “WINVER=0x0500” works for me. This way, -DWINVER=0x0500 is added to the command line of the compiler, which is the syntax GCC/mingw expects for command line preprocessor definitions (see here for the details).

qmake pre-build step before ANY compilation

Another option would be to start with the project file snippet in your original question, and also ensure that qmake is aware that versioning.h is a dependency for the other build targets in your project file — Add the full path to versioning.h to your HEADERS variable. Add the folder in which versioning.h resides to … Read more