The automoc documentation (http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_tgt:AUTOMOC) states that "all header files" are considered for automoc, which is not true for any sensible definition of "all header files".
Only header files with certain names are considered: specifically, if you have a C++ file like <file>.cpp attached to the target, header files like <file>.h and <file>_p.h will be considered. If you have a header file like foo.h and the corresponding source file is, say, foo_win.cpp, automoc will never look at foo.h. The attached patch makes the documentation clear on this point. Alex
Be clearer about which header files are considered for automoc The old documentation stated that "all header files" were considered, which was not true for any sensible definition of "all header files". Only header files with certain names are considered. --- Help/manual/cmake-qt.7.rst | 6 +++++- Help/prop_tgt/AUTOMOC.rst | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Help/manual/cmake-qt.7.rst b/Help/manual/cmake-qt.7.rst index eff73b3..1040e28 100644 --- a/Help/manual/cmake-qt.7.rst +++ b/Help/manual/cmake-qt.7.rst @@ -58,7 +58,11 @@ AUTOMOC The :prop_tgt:`AUTOMOC` target property controls whether :manual:`cmake(1)` inspects the C++ files in the target to determine if they require ``moc`` to -be run, and to create rules to execute ``moc`` at the appropriate time. +be run, and to create rules to execute ``moc`` at the appropriate time. It +also inspects header files named ``<file>.<hext>`` and ``<file>.<hext>`` for +each C++ file ``<file>.<cext>``, where ``<hext>`` is a known C++ header file +extension like ``h`` or ``hxx``, and ``<cext>`` is the extension of the C++ +file. If a ``Q_OBJECT`` or ``Q_GADGET`` macro is found in a header file, ``moc`` will be run on the file. The result will be put into a file named according diff --git a/Help/prop_tgt/AUTOMOC.rst b/Help/prop_tgt/AUTOMOC.rst index 16094c7..e6385e1 100644 --- a/Help/prop_tgt/AUTOMOC.rst +++ b/Help/prop_tgt/AUTOMOC.rst @@ -12,8 +12,9 @@ statement like ``#include "moc_foo.cpp"`` is found, the ``Q_OBJECT`` class declaration is expected in the header, and ``moc`` is run on the header file. If an ``#include`` statement like ``#include "foo.moc"`` is found, then a ``Q_OBJECT`` is expected in the current source file and ``moc`` is run on -the file itself. Additionally, all header files are parsed for -``Q_OBJECT`` macros, and if found, ``moc`` is also executed on those files. +the file itself. Additionally, header files with the same base name (like +``foo.h``) or ``_p`` appended to the base name (like ``foo_p.h``) are parsed +for ``Q_OBJECT`` macros, and if found, ``moc`` is also executed on those files. The resulting moc files, which are not included as shown above in any of the source files are included in a generated ``<targetname>_automoc.cpp`` file, which is compiled as part of the -- 1.8.5.3
-- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
