[CMake] FindPkgConfig: Using *_LIBRARY_DIRS

Murray Cumming murrayc at murrayc.com
Mon Oct 26 14:46:14 EDT 2009


On Fri, 2009-10-23 at 13:42 +0200, Murray Cumming wrote:
> pkg_search_module() defines SOMEPREFIX_LIBRARY_DIRS among other things,
> as mentioned here
> http://public.kitware.com/cgi-bin/viewcvs.cgi/Modules/FindPkgConfig.cmake?root=CMake&view=markup
> (better than the documentation at 
> http://www.itk.org/Wiki/CMake:How_To_Find_Libraries
> )
> 
> But how can I use those directories so my executable can actually be
> linked against the SOMEPREFIX_LIBRARIES libraries that I've specified to
> target_link_libraries().

I'm still stuck at this stage. I've tried doing this:

set_target_properties(qlom
        PROPERTIES
        LINK_FLAGS "${GLOM_LDFLAGS}")

But the linker flags then seem to be separated by ";" instead of spaces,
leading to error such as this:

c++: unrecognized option
'-pthread;-L/opt/gnome228/lib;-lglom-1.12;-lgiomm-2.4;-lgdamm-4.0;-lxml
++-2.6;-lgio-2.0;-lgmodule-2.0;-lgda-4.0;-lgthread-2.0;-lrt;-lxml2;-lglibmm-2.4;-lgobject-2.0;-lsigc-2.0;-lglib-2.0'

Surely there must be a simple way to use pkg-config?


My full CMakeList.txt so far is here, in case it's helpful:
c++: unrecognized option
'-pthread;-L/opt/gnome228/lib;-lglom-1.12;-lgiomm-2.4;-lgdamm-4.0;-lxml
++-2.6;-lgio-2.0;-lgmodule-2.0;-lgda-4.0;-lgthread-2.0;-lrt;-lxml2;-lglibmm-2.4;-lgobject-2.0;-lsigc-2.0;-lglib-2.0'
make[2]: Leaving directory `/home/murrayc/checkout/gnome/qlom_murrayc'
 

> Actually, I would much rather just tell the build system to use
> SOMEPREFIX_LDFLAGS instead of dealing with the directories and libraries
> separately. That's what I do with autoconf/automake.
> 
> 
> Also, if I use several libraries, do I need separate pkg_search_module()
> calls, and therefore several sets of variables? I'd much rather just
> give a list of libraries and get one set of CFLAGS and LDFLAGS. Again,
> that's what I do with autoconf/automake.

-- 
murrayc at murrayc.com
www.murrayc.com
www.openismus.com



More information about the CMake mailing list