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

Alexander Neundorf neundorf at kde.org
Fri Mar 12 15:10:25 EST 2010


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 ?

Alex



More information about the cmake-developers mailing list