[CMake] Does FIND_PACKAGE ignore REQUIRED and QUIET in Config mode ?

Yann Cointepas yann at sapetnioc.org
Fri Sep 5 07:27:20 EDT 2008


1) Why do I need Foo_FIND_QUIET in FooConfig.cmake ?
First, I would like to display a message with the Foo version found if QUIET
is not used.

2) Why do I need Foo_FIND_REQUIRED in FooConfig.cmake ?
FooConfig.cmake will be packaged and installed on various systems (in a
Foo-devel package). Therefore, even if FooConfig.cmake is found, I need to
check that its mandatory dependencies are found too before setting
Foo_FOUND. For instance, I have a mandatory dependency on Boost and I would
like to have the following code in FooConfig.cmake:

# Looking for Boost dependency
if( Foo_FIND_QUIET )
  find_package( Boost QUIET )
else( Foo_FIND_QUIET )
  find_package( Boost )
endifif( Foo_FIND_QUIET )

# Assert that all required dependencies are found
# and show messages depending on QUIET and
# REQUIRED options.
if( Boost_FOUND )
  set( Foo_FOUND true )
  if( NOT Foo_FIND_QUIET )
    message( STATUS "Found Foo" )
  endif( Foo_FIND_QUIET )
else( Boost_FOUND )
  set( Foo_FOUND false )
  if( NOT Foo_FIND_QUIET )
    if( Foo_FIND_REQUIRED )
      message( FATAL_ERROR "Found not found due to missing dependency" )
    else( Foo_FIND_REQUIRED )
      message( STATUS "Found not found due to missing dependency" )
    endif( Foo_FIND_REQUIRED )
endif( Boost_FOUND )


 The FooConfig.cmake use find_package( Boost )
> Hmm, I don't understand.
> You shouldn't need them in this case.
> If you use FooConfig.cmake, it will be found automatically, if not, i.e.
when
> you would have to check whether it was required or not, you are not able
to
> check it, since the script which could check it wasn't found and can't do
> anything.
> What exactly do you want to do ?
>
> Alex
>
> On Saturday 30 August 2008, Yann Cointepas wrote:
> > Hi,
> >
> > I would like to use XXX-config.cmake file (generated from a
> > XXX-config.cmake.in <http://xxx-config.cmake.in/>) in the same way as if
it was FindXXX.cmake (I want to
> > use the search policy of Config mode). But no XXX_FIND_REQUIRED nor
> > XXX_FIND_QUIET variables are defined when XXX-config.cmake is executed
with
> > find_package( XXX REQUIRED|QUIET ). Is there another way to get this
> > information ?



-- 
Yann Cointepas Tel: +33 1 69 08 78 31
CEA - Neurospin Fax: +33 1 69 08 79 80
Bâtiment 145, Point Courrier 156
91191 Gif-sur-Yvette cedex, France
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080905/dae467f1/attachment-0001.htm>


More information about the CMake mailing list