diff options
author | Orkun Tokdemir <ilhanorkuntokdemir@gmail.com> | 2023-05-31 15:17:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-05-31 16:59:28 (GMT) |
commit | 5e513e562ff66725ebb99e7cf83ad4579deebd8e (patch) | |
tree | 714a3fcadd8930c7bab7970a40c722bee2c54071 /Help | |
parent | 5380ad9d58c614aeaddb6be7a7fcc28cbf50c856 (diff) | |
download | CMake-5e513e562ff66725ebb99e7cf83ad4579deebd8e.zip CMake-5e513e562ff66725ebb99e7cf83ad4579deebd8e.tar.gz CMake-5e513e562ff66725ebb99e7cf83ad4579deebd8e.tar.bz2 |
Help: Add AUTOMOC_MOC_OPTIONS example
Diffstat (limited to 'Help')
-rw-r--r-- | Help/prop_tgt/AUTOMOC_MOC_OPTIONS.rst | 36 |
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 |