How to use QMake’s subdirs template?

In addition to Troubadour’s comment, I would note that the SUBDIRS target is only good for specifying subdirectories. Therefore, your extra line of SOURCES += main.cpp in your project.pro file is incorrect, and will likely fail to build your main.cpp file, at worst. At best, qmake will refuse to parse the file, since it has … Read more

QMake – how to copy a file to the output

You can use a qmake function for reusability: # Copies the given files to the destination directory defineTest(copyToDestdir) { files = $$1 for(FILE, files) { DDIR = $$DESTDIR # Replace slashes in paths with backslashes for Windows win32:FILE ~= s,/,\\,g win32:DDIR ~= s,/,\\,g QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t) } export(QMAKE_POST_LINK) } then use it … Read more

How to specify different Debug/Release output directories in QMake .pro file

For my Qt project, I use this scheme in *.pro file: HEADERS += src/dialogs.h SOURCES += src/main.cpp \ src/dialogs.cpp Release:DESTDIR = release Release:OBJECTS_DIR = release/.obj Release:MOC_DIR = release/.moc Release:RCC_DIR = release/.rcc Release:UI_DIR = release/.ui Debug:DESTDIR = debug Debug:OBJECTS_DIR = debug/.obj Debug:MOC_DIR = debug/.moc Debug:RCC_DIR = debug/.rcc Debug:UI_DIR = debug/.ui It`s simple, but nice! 🙂