summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-06-01 15:19:02 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-06-01 15:19:19 (GMT)
commitf6435f799ea7aa6669b035fee2a0559040890d27 (patch)
treebbbf240c1da7f73bf0ab4380fa814c5fb592bb7b /Help
parent99e80ea0ac2de2e0c24652c2af8589967996a0d4 (diff)
parent1f4b374d6e936960d902307bc9dcd4e8d93168e2 (diff)
downloadCMake-f6435f799ea7aa6669b035fee2a0559040890d27.zip
CMake-f6435f799ea7aa6669b035fee2a0559040890d27.tar.gz
CMake-f6435f799ea7aa6669b035fee2a0559040890d27.tar.bz2
Merge topic 'automoc-moc-options-test'
1f4b374d6e cmQtAutoGenInitializer: Reduce string copies b6f66b445a cmQtAutoGenInitializer: Remove no-op calls 55d93bdabf cmQtAutoGenInitializer: Improve const correctness feb56a666f cmTarget: Improve const correctness of AddUtility 5e513e562f Help: Add AUTOMOC_MOC_OPTIONS example 5380ad9d58 Tests: Add test for AUTOMOC_MOC_OPTIONS Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8523
Diffstat (limited to 'Help')
-rw-r--r--Help/prop_tgt/AUTOMOC_MOC_OPTIONS.rst36
1 files changed, 36 insertions, 0 deletions
diff --git a/Help/prop_tgt/AUTOMOC_MOC_OPTIONS.rst b/Help/prop_tgt/AUTOMOC_MOC_OPTIONS.rst
index 330849b..11ab147 100644
--- a/Help/prop_tgt/AUTOMOC_MOC_OPTIONS.rst
+++ b/Help/prop_tgt/AUTOMOC_MOC_OPTIONS.rst
@@ -15,3 +15,39 @@ is created, or an empty string otherwise.
See the :manual:`cmake-qt(7)` manual for more information on using CMake
with Qt.
+
+EXAMPLE
+^^^^^^^
+
+In this example, the ``moc`` tool is invoked with the ``-D_EXTRA_DEFINE``
+option when generating the moc file for ``object.cpp``.
+
+``CMakeLists.txt``
+ .. code-block:: cmake
+
+ add_executable(mocOptions object.cpp main.cpp)
+ set_property(TARGET mocOptions PROPERTY AUTOMOC ON)
+ target_compile_options(mocOptions PRIVATE "-D_EXTRA_DEFINE")
+ set_property(TARGET mocOptions PROPERTY AUTOMOC_MOC_OPTIONS "-D_EXTRA_DEFINE")
+ target_link_libraries(mocOptions Qt6::Core)
+
+``object.hpp``
+ .. code-block:: c++
+
+ #ifndef Object_HPP
+ #define Object_HPP
+
+ #include <QObject>
+
+ #ifdef _EXTRA_DEFINE
+ class Object : public QObject
+ {
+ Q_OBJECT
+ public:
+
+ Object();
+
+ };
+ #endif
+
+ #endif