diff options
Diffstat (limited to 'Help')
-rw-r--r-- | Help/manual/cmake-qt.7.rst | 11 | ||||
-rw-r--r-- | Help/prop_tgt/AUTOMOC.rst | 20 | ||||
-rw-r--r-- | Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst | 21 | ||||
-rw-r--r-- | Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst | 9 |
4 files changed, 32 insertions, 29 deletions
diff --git a/Help/manual/cmake-qt.7.rst b/Help/manual/cmake-qt.7.rst index 79e7e79..cafeae1 100644 --- a/Help/manual/cmake-qt.7.rst +++ b/Help/manual/cmake-qt.7.rst @@ -59,9 +59,10 @@ 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. -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 -to ``moc_<basename>.cpp``. If the macro is found in a C++ implementation +If a macro from :prop_tgt:`AUTOMOC_MACRO_NAMES` is found in a header file, +``moc`` will be run on the file. The result will be put into a file named +according to ``moc_<basename>.cpp``. +If the macro is found in a C++ implementation file, the moc output will be put into a file named according to ``<basename>.moc``, following the Qt conventions. The ``<basename>.moc`` must be included by the user in the C++ implementation file with a preprocessor @@ -95,9 +96,7 @@ following targets by setting the :variable:`CMAKE_AUTOMOC` variable. The options to pass to ``moc``. The :variable:`CMAKE_AUTOMOC_MOC_OPTIONS` variable may be populated to pre-set the options for all following targets. -The appearance of the strings ``Q_OBJECT`` or ``Q_GADGET`` in a source file -determines if it needs to be ``moc`` processed. To search for additional -strings, list them in :prop_tgt:`AUTOMOC_MACRO_NAMES`. +Additional macro names to search for can be added to :prop_tgt:`AUTOMOC_MACRO_NAMES`. Additional ``moc`` dependency file names can be extracted from source code by using :prop_tgt:`AUTOMOC_DEPEND_FILTERS`. diff --git a/Help/prop_tgt/AUTOMOC.rst b/Help/prop_tgt/AUTOMOC.rst index 4542401..641ac09 100644 --- a/Help/prop_tgt/AUTOMOC.rst +++ b/Help/prop_tgt/AUTOMOC.rst @@ -12,8 +12,8 @@ When this property is set ``ON``, CMake will scan the header and source files at build time and invoke moc accordingly. * If an ``#include`` statement like ``#include "moc_<basename>.cpp"`` is found, - the ``Q_OBJECT`` or ``Q_GADGET`` macros are expected in an otherwise empty - line of the ``<basename>.h(xx)`` header file. ``moc`` is run on the header + a macro from :prop_tgt:`AUTOMOC_MACRO_NAMES` is expected to appear in the + ``<basename>.h(xx)`` header file. ``moc`` is run on the header file to generate ``moc_<basename>.cpp`` in the ``<AUTOGEN_BUILD_DIR>/include`` directory which is automatically added to the target's :prop_tgt:`INCLUDE_DIRECTORIES`. @@ -26,11 +26,12 @@ source files at build time and invoke moc accordingly. * See :prop_tgt:`AUTOGEN_BUILD_DIR`. * If an ``#include`` statement like ``#include "<basename>.moc"`` is found, - then ``Q_OBJECT`` or ``Q_GADGET`` macros are expected in the current source - file and ``moc`` is run on the source file itself. + a macro from :prop_tgt:`AUTOMOC_MACRO_NAMES` is expected to appear in the + source file and ``moc`` is run on the source file itself. * Header files that are not included by an ``#include "moc_<basename>.cpp"`` - statement are nonetheless scanned for ``Q_OBJECT`` or ``Q_GADGET`` macros. + statement are nonetheless scanned for a macro out of + :prop_tgt:`AUTOMOC_MACRO_NAMES`. The resulting ``moc_<basename>.cpp`` files are generated in custom directories and automatically included in a generated ``<AUTOGEN_BUILD_DIR>/mocs_compilation.cpp`` file, @@ -44,8 +45,9 @@ source files at build time and invoke moc accordingly. * Additionally, header files with the same base name as a source file, (like ``<basename>.h``) or ``_p`` appended to the base name (like - ``<basename>_p.h``), are parsed for ``Q_OBJECT`` or ``Q_GADGET`` macros, - and if found, ``moc`` is also executed on those files. + ``<basename>_p.h``), are scanned for a macro out of + :prop_tgt:`AUTOMOC_MACRO_NAMES`, and if found, ``moc`` + is also executed on those files. * ``AUTOMOC`` always checks multiple header alternative extensions, such as ``hpp``, ``hxx``, etc. when searching for headers. @@ -69,9 +71,7 @@ automoc targets together in an IDE, e.g. in MSVS. The global property :prop_gbl:`AUTOGEN_SOURCE_GROUP` can be used to group files generated by :prop_tgt:`AUTOMOC` together in an IDE, e.g. in MSVS. -The appearance of the strings ``Q_OBJECT`` or ``Q_GADGET`` in a source file -determines if it needs to be ``moc`` processed. To search for additional -strings, list them in :prop_tgt:`AUTOMOC_MACRO_NAMES`. +Additional macro names to search for can be added to :prop_tgt:`AUTOMOC_MACRO_NAMES`. Additional ``moc`` dependency file names can be extracted from source code by using :prop_tgt:`AUTOMOC_DEPEND_FILTERS`. diff --git a/Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst b/Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst index 0639bc8..0535fde 100644 --- a/Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst +++ b/Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst @@ -1,20 +1,23 @@ AUTOMOC_MACRO_NAMES ------------------- -Additional macro names used by :prop_tgt:`AUTOMOC` -to determine if a C++ file needs to be processed by ``moc``. +A :ref:`;-list <CMake Language Lists>` list of macro names used by +:prop_tgt:`AUTOMOC` to determine if a C++ file needs to be processed by ``moc``. This property is only used if the :prop_tgt:`AUTOMOC` property is ``ON`` for this target. -CMake searches for the strings ``Q_OBJECT`` and ``Q_GADGET`` to -determine if a file needs to be processed by ``moc``. -:prop_tgt:`AUTOMOC_MACRO_NAMES` allows to add additional strings to the -search list. This is useful for cases where the ``Q_OBJECT`` or ``Q_GADGET`` -macro is hidden inside another macro. +When running :prop_tgt:`AUTOMOC`, CMake searches for the strings listed in +:prop_tgt:`AUTOMOC_MACRO_NAMES` in C++ source and header files. +If any of the strings is found + +- as the first non space string on a new line or +- as the first non space string after a ``{`` on a new line, + +then the file will be processed by ``moc``. By default :prop_tgt:`AUTOMOC_MACRO_NAMES` is initialized from -:variable:`CMAKE_AUTOMOC_MACRO_NAMES`, which is empty by default. +:variable:`CMAKE_AUTOMOC_MACRO_NAMES`. See the :manual:`cmake-qt(7)` manual for more information on using CMake with Qt. @@ -25,4 +28,4 @@ In this case the the ``Q_OBJECT`` macro is hidden inside an other macro called ``CUSTOM_MACRO``. To let CMake know that source files, that contain ``CUSTOM_MACRO``, need to be ``moc`` processed, we call:: - set_property(TARGET tgt PROPERTY AUTOMOC_MACRO_NAMES "CUSTOM_MACRO") + set_property(TARGET tgt APPEND PROPERTY AUTOMOC_MACRO_NAMES "CUSTOM_MACRO") diff --git a/Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst b/Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst index 7ed3445..5b79c40 100644 --- a/Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst +++ b/Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst @@ -1,14 +1,15 @@ CMAKE_AUTOMOC_MACRO_NAMES ---------------------------- -Additional macro names used by :variable:`CMAKE_AUTOMOC` -to determine if a C++ file needs to be processed by ``moc``. +A :ref:`;-list <CMake Language Lists>` list of macro names used by +:variable:`CMAKE_AUTOMOC` to determine if a C++ file needs to be +processed by ``moc``. This variable is used to initialize the :prop_tgt:`AUTOMOC_MACRO_NAMES` property on all the targets. See that target property for additional information. -By default it is empty. +The default value is ``Q_OBJECT;Q_GADGET;Q_NAMESPACE``. Example ------- @@ -16,4 +17,4 @@ Let CMake know that source files that contain ``CUSTOM_MACRO`` must be ``moc`` processed as well:: set(CMAKE_AUTOMOC ON) - set(CMAKE_AUTOMOC_MACRO_NAMES "CUSTOM_MACRO") + list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "CUSTOM_MACRO") |