[CMake] Pointing CMAKE_AUTOMOC to a custom version of Qt and its moc.exe

Saad Khattak saadrustam at gmail.com
Mon Nov 7 10:48:51 EST 2016


I am working on a plugin for Maya and it uses a customized version of Qt.
Maya's SDK comes with everything to build Qt (headers, libraries and
customized Qt tools such as moc.exe).

I have the following issues:

(1) With CMAKE_AUTOMOC set to ON, I am unable to figure out how to point
CMake to pick Maya's version of moc.exe (and other Qt utils). The result is
that I get linking errors since the moc did not run - which I expected.

(2) Maya uses a modified version of Qt 5.6.1. There is currently no way to
get that version from Autodesk. So I downloaded the official Qt 5.6.1
distribution. CMAKE_AUTOMOC now sets up my project correctly to be MOC'ed.
However, it is using the official Qt moc utilities and NOT Maya's
customized moc. The headers and libraries being used were still from Maya's
custom Qt.

The reason (2) worked is because I put "find_package(Qt5Widgets REQUIRED)"
after installing the official version of Qt 5.6.1. However, I did NOT use
the official Qt headers or libraries - instead, I used Maya's custom
version of Qt 5.6.1.

Using solution (2) I successfully compile and link my Qt enabled Maya
plugin and load it in Maya. Things go smoothly until I either (a) unload
the plugin or (b) delete any widget. I looked at the simplest code that is
causing a heap corruption debug assertion:

m_button = new QPushButton("MyButton"); // where m_button is a QPointer
<QPushButton>
delete m_button; // causes heap corruption debug assertion to fire

A few other people have gone through similar issues but since they didn't
use CMake, they simply ran Maya's moc utilities in a build step. I would
like a solution where I can get CMAKE_AUTOMOC to run the custom Qt version.

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161107/579bc3fa/attachment.html>


More information about the CMake mailing list