Nasty error message

Brad King brad.king at kitware.com
Wed Jul 12 19:26:38 CEST 2006


Adam Treat wrote:
> I had a class called Foo that was declared and implemented in the standard 
> files foo.cpp and foo.h
> 
> Foo inherited QObject and had the customary moc 
> include directive at the bottom: #include  "foo.moc"
> 
> During the course of events, I decided to rename this class FooBar, so I 
> changed the filename to foobar.cpp and foobar.h, respectively.  Unfortunately, 
> I forgot to change the include directive foo.moc :(
> 
> CMake did not like this and would not build, complaining that it could not 
> find the required file "foo.h"
> 
> So, I went through my source directory and could find no mention of foo.h nor 
> could I find the file.  grep foo.h * -r in the src directory AND build 
> directory turned up absolutely nothing.  I deleted the build directory and 
> started over.  Same error message.  I could not figure out how in the hell 
> would cmake complain to me about a file that was not mentioned ANYWHERE in 
> any file in either the source directory or the build directory.
> 
> After quite a lot of lost time, I finally figured out that it was referring to 
> the foo.moc directive that I forgot to change.
> 
> Could the CMake gurus be so kind as to have CMake complain about foo.moc 
> instead of foo.h if this happens again?

Are you using some kind of auto-moc macro?  I bet it encounters the 
"foo.moc" in the source file, and says "okay, to get foo.moc I need to 
inspect foo.h".  Then it looks for foo.h and cannot find it.  The error 
message produced by the macro should be improved to indicate why it is 
looking for foo.h.

-Brad


More information about the Kde-buildsystem mailing list