[CMake] PKGCONFIG("dbus-1 >= 1.0.0" ...) should also possible

Claus Klein claus.klein at arcormail.de
Fri Jan 12 06:32:32 EST 2007


On Friday 12 January 2007 11:39, Axel Roebel wrote:
> On Friday 12 January 2007 10:17, Claus Klein wrote:
> > On Friday 12 January 2007 08:43, Alexander Neundorf wrote:
> > > Von: Claus Klein <claus.klein at arcormail.de>
> > >
> > > > Hi,
> > > >
> > > > to be more flexible, here is a patch for UsePkgConfig.cmake
> > > >
> > > > #   PKGCONFIG("dbus-1 >= 1.0.0" ...) is now also possible.
> > > >
> > > > #   Optional, for stage building, the
> > > > #   PKGCONFIG_OPTIONS and PKG_CONFIG_PATH environment variable are used
> > >
> > > ...
> > >
> > > Thanks for the patch, but please have a look at the new
> > > FindPkgConfig.cmake module, which is much more powerful than the "old"
> > > and now obsolete UsePkgConfig.cmake. I think FindPkgConfig.cmake should
> > > already be able to do what you want.
> > >
> > > Bye
> > > Alex
> >
> > Yes, if found this new Module yesterdy. But for me, a PKGCONFIG_OPTIONS env
> > var should supported too!
> >
> > The name my be changed, but this prepeares more flexibility and this is
> > needed for cross-compile builds.
> >
> > from man pkg-config(1):
> >        --define-variable=VARIABLENAME=VARIABLEVALUE
> >               This  sets  a  global value for a variable, overriding the
> > value in any .pc files. Most packages define the variable "prefix", for
> > example, so you can say:
> >                 $ pkg-config --print-errors --define-variable=prefix=/foo \
> >                              --variable=prefix glib-2.0
> >                 /foo
> >
> >
> > If this is not possible, I have always to edit the *.pc files in my stage
> > dir after installation like that:
> >
> > 	sed -i -e "s#/usr#/mystagedir#g" /mystagedir/lib/pkgconfig/*.pc
> >
...

> >
> > PS.  I find cmake a good tool and I will continue to test it, but my scope
> > is the embedded world, so I need to cross-compile. It is very hard to write
> > patches for each new version of a used package, if the developer don't care
> > about that!
> 
> For me it is rather difficult to understand what the --define-variable thing 
> may be good for. Isn't 
> 
> $> pkg-config --print-errors --define-variable=prefix=/foo  --variable=prefix glib-2.0
> 
> more or less equivalent to
> 
> $> if pkg-config --exists glib-2.0 ; then  echo /foo; fi
> 
> ???
it is not useful to test thel lib version. But:

PKG_CONFIG_PATH=/tools/LinuxPpcCDK/lib/pkgconfig/ \
  pkg-config --libs --print-errors dbus-1
-L//lib -ldbus-1                <<<<<<<<<<<<<<<<<<< this would be wrong!


PKG_CONFIG_PATH=/tools/LinuxPpcCDK/lib/pkgconfig/ \
 pkg-config --libs --print-errors --define-variable=prefix=/tools/LinuxPpcCDK dbus-1
-L/tools/LinuxPpcCDK/lib -ldbus-1

This is are the LinkFlags I need!


> 
> Anyway:
> 
> You may just add a local directory of cmake modules into your project
> and keep your own versions of the .cmake files there if the standard 
> ones don't serve what you need. 

Yes I could, but this is stupid to do for every different package I use.

If the packages are portable and flexible, and cmake is used in this way
(every lib should support a pkg-config!), using another project which
depend on this lib would be more easy.

I will say to all package mantainers: 

  "Use cmake and support pkg-config, and don't use TRY_RUN()!"


Bye
Claus



More information about the CMake mailing list