Suppose I have a C++ file named animals.cpp
. How can I generate a moc file (moc_animals.cpp
) using CMake?
Asked
Active
Viewed 3,705 times
2 Answers
5
There are multiple ways. if you are using CMAKE version grater than 2.8.6 then you can use AUTOMOC which should do everything automatically for you.
Here there is a nice tutorial.
As pointed out by @spectras this assumes respecting their naming convention. If you want to use your specific naming you can of course use the manual mechanism by simple calling qt4_wrap_cpp
or qt5_wrap_cpp
. This is also what you should do in case you are bound to older CMAKE versions.

Stefano
- 3,981
- 8
- 36
- 66
-
1This is the correct way, if you follow the nomenclature that comes with it. If you don't for some reason, you may still resort to manual `qt4_wrap_cpp` or `qt5_wrap_cpp`. – spectras Sep 01 '17 at 07:36
-
yes... I will add your comment to my answer then... thanks! – Stefano Sep 01 '17 at 07:46