[cmake-developers] pkg-config like mode for cmake ?

Alexander Neundorf neundorf at kde.org
Fri Mar 12 16:20:21 EST 2010


On Friday 12 March 2010, Eric Noulard wrote:
> 2010/3/12 Alexander Neundorf <neundorf at kde.org>:
> > Hi,
> >
> > when discussing with Marcus, we had an idea.
> > Since 2.6.0 cmake can install FooConfig.cmake export files to help with
> > finding installed software via the find_package() command.
> >
> > This is very nice and useful as long as you are using cmake yourself for
> > your project. If you are using something else, e.g. plain Makefiles (or
> > autotools or whatever), these installed export-files are more or less
> > unusable for you. Some cmake projects additionally install pkgconfig
> > pc-files, but then you rely on pkg-config, which IMO sucks.
> >
> > How about doing it just vice versa ?
> > Instead of installing pc-files, add a mode to cmake so it acts
> > pkgconfig-like, i.e. it searches for the package and prints the required
> > compiler flags to stdout ?
> >
> > Like
> > $ cmake --findpackage Foo --libs
> > would basically execute a
> > find_package(Foo NO_MODULE)
> > then see which imported libraries have been executed, and then print the
> > linker flags to link these libraries.
> > For the include dirs one would have to rely on these variables named
> > properly FOO_INCLUDES, FOO_INCLUDE_DIRS, FOO_INCLUDE_DIR or FOO_INCLUDE,
> > probably in this order.
> >
> > What do you think ?
>
> Very nice idea
> +1 on my side.
>
> However the cross platform nature of CMake would make me think that
> something like:
>
> cmake -G<GeneratorName> --findpackage Foo --libs
> may be better.
>
> Because I think that the "linker flags" output may well depend on the
> platform/compiler combination, or am I wrong?

I think it does, and this is IMO also one of the problems of pkg-config, it 
just returns a set of compiler flags, which are hopefully ok for the compiler 
you are using.

Alex



More information about the cmake-developers mailing list