Development/Tools/Automoc4: Difference between revisions

From KDE TechBase
(New page: This wiki page will document automoc4. ==Usage== ==Features== ==When are which files generated== ==What doesn't work==)
 
Line 2: Line 2:


==Usage==
==Usage==
You should not use the automoc4 executable directly. Instead include the Automoc4Config.cmake file in your CMakeLists.txt (best use [http://websvn.kde.org/*checkout*/trunk/KDE/kdelibs/cmake/modules/FindAutomoc4.cmake FindAutomoc4.cmake]). Then you can add two lines per target to your CMakeLists.txt and you never need to worry about moc files anymore:
set(foobar_srcs main.cpp foobar.cpp)
add_executable(foobar ${foobar_srcs})
then becomes
set(foobar_srcs main.cpp foobar.cpp)
add_automoc4_target(foobar_automoc foobar_srcs)
add_executable(foobar ${foobar_srcs})
add_dependencies(foobar foobar_automoc)
The add_automoc4_target macro adds a new target, which, when called, generates all moc files and a source file to include those when needed and adds the name of that source file to foobar_srcs.
The add_dependencies macro tells cmake to add a dependency such that foobar only gets called after foobar_automoc is done.


==Features==
==Features==

Revision as of 15:57, 17 July 2008

This wiki page will document automoc4.

Usage

You should not use the automoc4 executable directly. Instead include the Automoc4Config.cmake file in your CMakeLists.txt (best use FindAutomoc4.cmake). Then you can add two lines per target to your CMakeLists.txt and you never need to worry about moc files anymore:

set(foobar_srcs main.cpp foobar.cpp)
add_executable(foobar ${foobar_srcs})

then becomes

set(foobar_srcs main.cpp foobar.cpp)
add_automoc4_target(foobar_automoc foobar_srcs)
add_executable(foobar ${foobar_srcs})
add_dependencies(foobar foobar_automoc)

The add_automoc4_target macro adds a new target, which, when called, generates all moc files and a source file to include those when needed and adds the name of that source file to foobar_srcs.

The add_dependencies macro tells cmake to add a dependency such that foobar only gets called after foobar_automoc is done.

Features

When are which files generated

What doesn't work