[cmake-developers] Automoc same source - More thoughts

Sebastian Holtermann seblist at xwmw.org
Tue Apr 12 11:40:44 EDT 2016


Am 12.04.2016 um 13:43 schrieb Sebastian Holtermann:
> Sorry for the noise.
>
>> I've stumbled over bug
>> https://cmake.org/Bug/view.php?id=12873
>> a few times now since I like to use same named data/view classes.
>>
>> I've prepared a fix that generates all moc_xxx.cpp files
>> in the foo_automoc.dir subdirectory.
>

I had some more thoughts about this.

CMAKE_CURRENT_BINARY_DIR /
   foo_automoc.cpp
   foo_automoc.dir/data/moc_item.cpp
   foo_automoc.dir/view/moc_item.cpp
   foo_automoc.dir/moc_item.cpp

With directory based moc file generation it is complicated to allow 
"#include <moc_foo.cpp>" (I've never included mocs btw.).
Putting every moc directory into the target INCLUDE_DIRECTORIES
won't help because then there would be multiple moc_item.cpp
files that match "include <moc_item.cpp>".
If per source INCLUDE_DIRECTORIES were possible it might work though.

My proposal is this:

- Moc files that are "#include<>"d get generated in
CMAKE_CURRENT_BINARY_DIR/moc_xxx.cpp as before but with
name collision test.

- Moc files not included but detected from
headers get generated in
CMAKE_CURRENT_BINARY_DIR/foo_automoc.dir/
with subdirectory support.
Since they're not included it doesn't matter where they are as long as
they don't overwrite each other.


I'll prepare another patch for this...

Kind regards,
Sebastian





More information about the cmake-developers mailing list