On 2010-11-22 21:55+0100 Alexander Neundorf wrote:

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 ?

Hi Alex:

How did you collect that compiler flag information?  As far as I know
the command "install(EXPORT ....)" only writes out information about
the link flags but not the compile flags associated with a given
library target. If your method of obtaining compile flag information
is general enough, then it should be straightforward to modifiy that
install signature to write out the compile flags as well, and that
would be a huge win.

For example, PLplot currently uses install(EXPORT ....) to collect
link flag information for all its libraries for the use of external
projects.  And we use that information for an external CMake-based
build system we have implemented to build and exhaustively test our
installed examples. That build system would be a lot less cumbersome
if we had access to compile flags for each of our libraries through
the EXPORTed cmake file.

Thus, in answer to your primary question, I think the cmake file
written out by install(EXPORT ...) is the right format to use for
compile flag and linker flag information if the above suggested
enhancement to install(EXPORT...) was made.  Once compile and link
flag data were collected in a format like that, it should be a simple
matter to parse those data into any other form that developers might
like including dumping those data directly to the command line as in
your proof of concept above.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
_______________________________________________
cmake-developers mailing list
cmake-developers@cmake.org
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to