On Tuesday 07 June 2011, Alexander Neundorf wrote:
> On Monday, June 06, 2011 03:44:20 PM Brad King wrote:
> > On 06/05/2011 07:14 PM, Eric Noulard wrote:
> > >>> 2011/6/4 Alexander Neundorf <neund...@kde.org>:
> > >>>> * if so, it will check that for FOO_INCLUDES and FOO_LIBRARIES
> > >>>> * create the command line arguments for the compiler from that
> > >>>> * print "-I/opt/foo/include" to stdout
> > 
> > [snip]
> > 
> > > cmake-config would be a [portable] script (or even minimalistic
> > > binary), which basically call
> > > a cmake script (for portability).
> > 
> > This may be technically challenging, especially for the link options.
> > CMake's link line generation happens at generation time and is not
> > accessible to the CMake language.  Furthermore, it depends on a lot
> > of information about the final library or executable because it is
> > an expert system [1] (e.g. implicit language runtime libraries for
> > mixed executables, transitive dependencies, etc.).
> 
> I have it basically working here now, including a cmake.m4 macro so you can
> do CMAKE_CHECK_MODULE() in configure.in.
> 
> Checking whether a package has been found is straightforward.
> 
> For creating the compile flags I'm using
> localGen->GetIncludeFlags(language.c_str(), false);
> 
> For the linking I currently get the FOO_LIBRARIES variables, create an
> empty executable target, set the LINKER_LANGUAGE to what the user wants,
> add all the libraries to the executable and then call
> localGen->GetTargetFlags()
> 
> This is what I get currently, the stuff for libxml2 is from cmake via
> FindLibXml2.cmake (with an additional libbar.so):
> 
> ~/src/tests/pkgconfig/pkgconfig> ./configure
> checking for pkg-config... /usr/bin/pkg-config
> checking pkg-config is at least version 0.9.0... yes
> checking for QtSQL... yes
> Result: CFLAGS: -DQT_SHARED -I/usr/include/QtSql -I/usr/include/QtCore  
> LIBS: -lQtSql -lQtCore
> checking for QtXML... yes
> Result: CFLAGS: -DQT_SHARED -I/usr/include/QtXml -I/usr/include/QtCore  
> LIBS: -lQtXml -lQtCore
> checking for XFT... yes
> Result: CFLAGS: -I/usr/include/freetype2   LIBS: -lXft
> checking for LIBXML2... LibXml2 found.
> LibXml2 found.
> yes
> Result: CFLAGS: -I/usr/include/libxml2   LIBS: -rdynamic -lxml2
> /opt/bar/lib/libbar.so -Wl,-rpath,/opt/bar/lib   -fPIC
> configure: creating ./config.status
> config.status: creating Makefile

I improved it somewhat, so IMO it is basically working now.
There is now a branch UsingCMakeLikePkgConfig on stage.
Would be nice if you could have a look.
Having this in cmake would make it unnecessary that library developers need to 
install both a FooConfig.cmake file and a foo.pc file.

And it works IMO better than pkg-config :-)

My m4-skills are basically non-existant.

Alex
_______________________________________________
cmake-developers mailing list
cmake-developers@cmake.org
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to