Automatic recording of required packages...

Alexander Neundorf neundorf at
Wed Nov 3 22:39:15 CET 2010

On Tuesday 02 November 2010, David Faure wrote:
> On Monday 01 November 2010, Alexander Neundorf wrote:
> > Here cmake reports an error in target_link_libraries():
> >
> >
> > -- Could NOT find Foo  (missing:  FOO_LIBRARY)
> > CMake Error: The following variables are used in this project, but they
> > are  set to NOTFOUND.
> > Please set them or make sure they are set and tested correctly in the
> > CMake  files:
> >     linked by target "hello" in directory /home/alex/src/tests/foo
> >
> > -- Configuring incomplete, errors occurred!
> Would there be a way to make cmake hide such errors, if it already saw a
> failing find_package(Foo REQUIRED)?
> I.e. upon a failure to find a required package
> 1) enter "degraded" mode:
> 2) keep going, to possibly look for more packages
> 3) skip any errors about variables containing NOTFOUND like the above
> 4) call feature_summary() to show all missing packages
> (ideally this would even be automated, so that this mechanism does not
> break when someone forgets to call feature_summary())
> This is a bit like C++ compilers attempt to recover from errors in order to
> show more than one error :-)
> On the other hand, I have seen cmake errors where the error would just be a
> line in the output, but without stopping there nor listing a missing
> dependency at the end, making it really hard to find the error. So if the
> above (my ideal solution) is not possible, 

I don't think I could convince the other cmake developers to implement 
something like this.
Hmm. CMake kind of knows when a find_package() failed, but not really.
I mean, it's up to the find-module to call 
message(FATAL_ERROR) if it failed.
If it doesn't do that, it should at least set <PACKAGE>_FOUND to FALSE.
This is recommended, and every Find-module should do that, but it's not 
Assuming every find-module would set <PACKAGE_FOUND> to TRUE or FALSE, cmake 
knows whether the find_package() has been successful. This is what is 
currently done for the "automatic recording of required packages" (see 
initial email).
The find-module probably printed
-- Package FOO was not found !
and then cmake continues.
Let's say now it hits a place which would trigger the error "variable is set 
to NOTFOUND but used".
What should it do ?
Ignore it, since a find_package() failed ?
This would mean also ignoring it if it is for an unrelated variable from 
another find-module.
Would you think that's ok ?

But also other things can go wrong when skipping the "REQUIRED" argument:

execute_process(COMMAND ${FLEX_EXECUTABLE} -some -weird -arguments)

And probably many more ways to break...


More information about the Kde-buildsystem mailing list