[cmake-developers] Using cmake pkg-config-like in non-cmake builds
Alexander Neundorf
neundorf at kde.org
Mon Nov 22 15:55:22 EST 2010
Hi,
there can be the case that a package which has been built with cmake, should
be used in a project which doesn't use cmake.
There is a feature request that cmake should help with generating pkg-config
pc-files: http://public.kitware.com/Bug/view.php?id=11446
I don't like that idea, because a) this means duplicating information, and b)
doing that in a less powerful format.
I have a slightly different idea: instead of having cmake generate pc-files,
modify/extend cmake so that it can be used similar to pkg-config by projects
which don't use cmake as their buildsystem.
I attached a first very quick try to that bug report.
It's a small cmake script which can be executed by cmake with -P, and which
basically contains one find_package() call and prints the results, so they
can be fed into a compiler invocation in a makefile.
It already somewhat works:
$ cmake -DMODE=COMPILE -DCOMPILER_ID=GNU -DPACKAGE=PNG -P cmake-config.cmake
-I/usr/include -I/usr/include
$ cmake -DMODE=LINK -DCOMPILER_ID=GNU -DPACKAGE=PNG -P cmake-config.cmake
/usr/lib/libpng.so /usr/lib/libz.so
Do you think this makes sense ?
Current issues:
* the output goes to stderr instead stdout
* the output has line breaks
* actual problem: currently it's not possible to use commands which deal with
targets in script-mode (I disabled that in 2007 since at least back then it
didn't make sense). This means that find-modules which use try_compile()
internally fail, and also those which create imported targets.
Do you think it is worth to put some effort into this ?
Alex
More information about the cmake-developers
mailing list