CMakeLists.txt

This assumes that you've installed KDE4 and kdebindings. If you only have SmokeQt installed, you need to adjust the paths accordingly.

How to create a SMOKE lib

To generate SMOKE libs for your own libs and APIs, a new tool has been written, called 'smokegen'. It's included in kdebindings since KDE SC 4.4. We're still missing a FindSmokegen.cmake file, but it's being worked on. Still, here's a quick tutorial to generate your own smoke lib:

smokegen itself only does the parsing of C++ header files, it then expects a plugin which does something useful with the parsed information. Currently there are two plugins (called a 'generator') available: the 'dump' generator, which simply prints the available classes to stdout, and the 'smoke' generator, which actually generates the Smoke source files.

Setting up the parser

For convenience, the options and switches that smokegen requries are stored in an xml-file. Such config files for Qt-based APIs and KDE-based APIs are already installed with the smokeqt and smokekde libs (in <prefix>/share/smokegen). Give them to smokegen with the -config option, as in

smokegen -config/usr/share/smokegen/kde-config.xml

You can extend options, like include dirs, by giving additional parameters on the command line. For example, you can give additional include dirs with the -I flag:

smokegen --help will show a complete list of possible options. You'll typically only need -I, -dm, -o and sometimes -g (the default generator in the config.xml files is 'smoke', but sometimes you might want to override it with 'dump' to get a list of classes).

smokegen then expects a list of headers after a double dash. Typically we write an 'include-all' header, like Qt does, to simplify matters. It's also the most secure way to conditionally include headers (on different platforms for example) and later get the smoke compilation right. Such an include file could look like this:

// the parser doesn't understand the __attribute__ stuff of GCC - disable it for the smokegen run.#define MYAPP_EXPORT// Since KDE 4.5 this is also supported (and encouraged):// #ifdef __SMOKEGEN_RUN__// # define MYAPP_EXPORT// #endif// This is needed on windows platforms, where MYAPP_EXPORT typically expands// to __dllimport and is needed for successful compilation.#include <myheader_a.h>#include <myheader_b.h>#include <subdir/myheader_c.h>

Setting up the SMOKE generator

Now we still need a smokeconfig.xml for our 'smoke' generator, so that it knows what our modules is called, which parent modules it has, what classes should be included, etc. For elaborate smokeconfig.xml files you can take a look at the ones for the various smoke libs shipped in the kdebindings module, in the subdirs smoke/<moduleName>/smokeconfig.xml.
A very simple smokeconfig.xml would look like this:

<config><moduleName>myapp</moduleName><!-- Our classes inherit from classes that are in the kdecore and kdeui modules. --><parentModules><module>kdecore</module><module>kdeui</module></parentModules><!-- how many source files should the generator create? --><parts>10</parts><!-- the following two sections are needed for every Qt based module! --><scalarTypes><!-- QString is a class, but represented as a scalar (#) in munged names --><typeName>QString</typeName></scalarTypes><voidpTypes><!-- both are classes, but they are represented as Smoke::t_voidp --><typeName>QStringList</typeName><typeName>QString</typeName></voidpTypes><!-- regexps for signatures of methods and functions that we don't want to be wrapped in the smoke module --><exclude><!-- we don't want these private members in smoke.. --><signature>.*::d_ptr.*</signature><signature>.*::q_ptr.*</signature><!-- we also don't want internalFunction(MyType*) in the smoke lib --><signature>.*internalFunction\(MyType\*\).*</signature></exclude><!-- regexps for signatures of top-level functions we want to have included --><functions><!-- include functions starting with 'myapp' --><name>^myapp.*</name><!-- and operators --><name>.*operator.*</name></functions><classList><class>MyClassA</class><class>MyClassB</class><class>MyNamespaceA::MyClassC</class><class>MyNamespaceA::MyClassC::MyNestedClass</class></classlist></config>

And this is it. If you run the command (of course it has to be adjusted to use your own headers and classnames), you should end up with a smokedata.cpp and a bunch of x_*.cpp files which you can compile into one libsmokemyapp.so library.