Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making moc skip files/folders during build

Tags:

qt

libstdc++

moc

It is a known bug that moc trips over macros used in libstdc++ as documented here: http://lists.kde.org/?l=necessitas-devel&m=132317657926916&q=raw

I am trying to compile a project which uses gcc 4.6.3 and am stuck because moc trips over the macros.

One way to overcome the problem is to include the directives as mentioned in this link:

http://doc.qt.io/qt-4.8/moc.html

but that is time consuming and not a very clean way as every file has to have these directives.

What I'd like to know is, can qmake be configured such as to make moc skip certain directories/files?

edited: typos

like image 906
hasan Avatar asked Nov 04 '22 04:11

hasan


1 Answers

According to the Qt qmake docs moc will be run for files that are added to the HEADERS variable (emphasis mine):

qmake will generate dependency information (unless -nodepend is specified on the command line) for the specified headers. qmake will also automatically detect if moc is required by the classes in these headers, and add the appropriate dependencies and files to the project for generating and linking the moc files.

So if you don't want moc to be run for certain files then don't add them to the HEADERS in your .pro file. However, for some platforms that might cause the headers not to be found when compiling the corresponding .cpp files. To fix that, add an INCLUDEPATH for the folders containing such headers - moc won't be run for headers that are inside an INCLUDEPATH.

like image 105
Cutterpillow Avatar answered Nov 15 '22 07:11

Cutterpillow