Hi, IMHO, both proposals are too Qt/KDE specific to be integrated into cmake this way. Maybe cmake could provide a more generic approach like allowing you to run whatever dependency scanner at some stage in the build process.
-Nico On Saturday, June 4, 2011, Alexander Neundorf <neund...@kde.org> wrote: > Hi, > > one feature which all KDE developers are used to and which is also used by > qmake when building Qt is "automoc". > > This means that you don't have to write > qt4_wrap_cpp(srcs ${filesToBeMoced}) > > but instead you simply do > kde4_add_executable(hello ${srcs}) > and everything including moc is handled automatically. > > This is done so that in your foo.cpp file you include the moc-file e.g. at the > end: > > ------------------- > > Foo::Foo() > :QObject() > { > } > ... > > void Foo::doSomething() > { > } > > #include "foo.moc" > > ---------------- > > > What needs to be done for this is to parse all source files for such include > lines at build time (because such a line may have been inserted without > changing anything in CMakeLists.txt) and if such a line is found, moc has to > be started and the file has to be generated. > > Currently this is done by the tool automoc4 which is a separate package. > It consists of a binary automoc4 and a macro > automoc_add_executable(). > > What this macro basically does is to add for each target foo an additional > target foo_automoc, and make the target foo depend on foo_automoc. So > foo_automoc is always built before foo. > > The custom target foo_automoc basically runs the automoc4 executable, which > checks for all source files whether they have changed, and whether they > contain moc-include statements, and if so, it runs moc. > > > So, we'd like to have that available in cmake. > > I see two ways how to do it: > > 1) keep the mechanism as it is, but integrate the functionality of the automoc > executable into cmake, so that the custom target would do cmake --automoc or > something like this. > This would still need an additional macro, which would then probably be > qt_add_executable(). > When doing automoc, the list of source files has to be known, the include > directories and the defines. > This is currently written into a file which is then loaded by automoc4. > When integrating it this way, this would probably stay more or less like this. > > 2) Integrate it fully into cmake, i.e. add arguments to add_executable() and > add_library(), so I can do > add_executable(foo AUTOMOC ${srcs} ) > > Advantages of this would be that it doesn't need an extra macro and extra > custom target to be set up, and that the information like the list of files > and include directories is directly available in cmAddExecutable, so it > doesn't have to be written in a separate file which is read later on. > > > So, we'd really like to have that integrated in cmake. > What do you think ? Which way would you prefer ? I think I'm favouring option > 2). > > I'll work in the next days on porting current automoc away from using Qt to > plain STL (and kwsys), so that it becomes ready for inclusion. It is also > already BSD licensed. > > > Alex > _______________________________________________ > cmake-developers mailing list > cmake-developers@cmake.org > http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers > -- Nicolas Desprès _______________________________________________ cmake-developers mailing list cmake-developers@cmake.org http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers