CMake check for create-resources

Alexander Neundorf neundorf at kde.org
Fri Feb 15 23:43:11 CET 2008


On Friday 15 February 2008, Sven Langkamp wrote:
> On Wed, Feb 13, 2008 at 8:06 PM, Alexander Neundorf <neundorf at kde.org>
>
> wrote:
> > On Wednesday 13 February 2008, you wrote:
> > > On Feb 12, 2008 6:28 PM, Alexander Neundorf <neundorf at kde.org> wrote:
> > > > On Tuesday 12 February 2008, Sven Langkamp wrote:
> > > > > Hi,
> > > > >
> > > > > I want to add a dependency for the create-resources package to
> >
> > KOffice,
> >
> > > > > which contains shared resources from the CREATE project.
> > > > > How can I check if the package is installed? Note that the package
> >
> > only
> >
> > > > > contains data and no code.
> > > >
> > > > What does this package consist of and where is it typically installed
> >
> > ?
> >
> > > > You probably need to do something with find_path().
> > >
> > > On my system it's in /usr/share/create/ and it contains brush, pattern
> >
> > and
> >
> > > gradient files.
> > >
> > > I tried to put a FindCreateResources.cmake in koffice/cmake/modules,
> > > but that doesn't work and is probably not even valid cmake code:
> > >
> > > if(CREATERESOURCES_INCLUDE_DIR)
> > >
> > >   set(CREATERESOURCES_FOUND TRUE)
> > >
> > > else(CREATERESOURCES_INCLUDE_DIR)
> > >
> > >   find_path( CREATERESOURCES_INCLUDE_DIR simple.kgr /usr/share/create/
> > > ) if( CREATERESOURCES_INCLUDE_DIR )
> > >     set( CREATERESOURCES_FOUND TRUE )
> > >   endif( CREATERESOURCES_INCLUDE_DIR )
> > > endif(CREATERESOURCES_INCLUDE_DIR)
> > >
> > > find_package(createresources REQUIRED) gives CMake Error:
> > > createresources_DIR is not set.  It must be set to the directory
> >
> > containing
> >
> > > createresourcesConfig.cmake in order to use createresources.
> >
> > The filename is FindCreateResources.cmake, so must use exact that case:
> > find_package(CreateResources)
>
> Thanks, this worked.
>
> > I'd suggest to start simple:
> >
> > find_path( CREATERESOURCES_INCLUDE_DIR simple.kgr
> >            PATHS
> >           ${CMAKE_INSTALL_PREFIX}
> >           /usr /usr/local /usr/pkg
> >           /opt /opt/local /opt/csw
> >           PATH_SUFFIXES share/create )
> >
> > if( CREATERESOURCES_INCLUDE_DIR )
> >  set( CREATERESOURCES_FOUND TRUE )
> > endif( CREATERESOURCES_INCLUDE_DIR )
> >
> > (with cmake cvs it wouldn't be necessary to list all these paths, there
> > it has
> > CMAKE_SYSTEM_PREFIX_PATH which has all these search prefixes)
> >
> > Does that project have a homepage ?
>
> Is there a way to see if the package was found? At the moment cmake runs,
> but I don't get feedback from it.

Yes.
You can do the following:

find_package(CreateResources)

if(CREATERESOURCES_FOUND)
  message(STATUS "Create Resources found")
endif(CREATERESOURCES_FOUND)

or you can grep for CREATERES in CMakeCache.txt and see what it contains.

Or you can do "make edit_cache" and check that way for 
CREATERESOURCES_INCLUDE_DIR

or (even better) you can do the following in FindCreateResources.cmake:

find_path(...)

find_package_handle_standard_args(CreateResources DEFAULT_MSG
                                                  CREATERESOURCES_INCLUDE_DIR)


If you need to find more than one file, use find_path() for all of them and 
list the result variables in the find_package_handle_standard_args() macro.
( you can remove the if(CREATERESOURCES_INCLUDE_DIR) 
set(CREATE_RESOURCES_FOUND TRUE) then, this is handled by the macro above.

Alex


More information about the Kde-buildsystem mailing list