How to detect target architecture using CMake?

So I devised a rather creative solution to my problem… it appears that CMake has no functionality to detect the target architecture whatsoever. Now, we know we can easily do this in C because symbols like __i386__, __x86_64__, etc., will be defined depending on your environment. Fortunately CMake has a try_run function which will compile … Read more

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! 🙂