[CMake] Cmake and pkg-config and linking
Tim Teulings
rael at edge.ping.de
Sun Jul 30 04:45:41 EDT 2006
Hello!
> Look for PKGCONFIG in http://www.cmake.org/HTML/Documentation.html. There
> you will find it already gives you includedir, libdir, linkflags, and
> cflags. If you look at the implementation (Modules/UsePkgConfig.cmake),
> the
> last two arguments return the equivalent of --libs and --cflags, and it
> would be extraordinarily easy (just a few lines of extra code) to define an
> enhanced version of UsePkgConfig.cmake for your own use to deliver the
> remaining flags that you ask for above. I agree those additonal flags are
> important so I hope this enhancement also quickly gets into the official
> UsePkgConfig.cmake as well.
OK, my initial mail was not complete. I already use the build in
PKGCONFIG macro. But: The first two result values are empty and I have
problems passing the resulting two macros to appropriate CMake variables
or macros, because if I use one of the above solution the resulting make
file is buggy, since I passed arguments to the linker in the wrong order
(see my initial mail).
However I can see that there are also the macros LINK_DIRECTORIES and
LINK_LIBRARIES. But to fill them I have to parse and modify the result
of the PKGCONFIG macro. I foresee problems in this case if directory
names contain spaces.
On the other hand PKGCONFIG already has options to directly return
apropiate values for these two variables, so why are they not used in
the PKGCONFIG macro? I would expect that the result of the PKGCONFIG
macro is already optimal prepared for easy call of CMake macros. It does
not make sense to put the burden of postprocessing to every makefile if
this postprocessing of pkg-config executable return values can be done
*in* the PKGCONFIG macro.
--
Gruß...
Tim.
More information about the CMake
mailing list