[CMake] using icu-config (or any other)

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sat Oct 20 18:45:22 EDT 2007


On 2007-10-20 22:26+0200 Mathias Baumann wrote:

> Hi there,
> I got a lib (icu), this lib provides also a icu-config script/binary which 
> tells me the compiler/linker flags..
> So i can use icu-config --ldflags to find out the parameter for the linker.
> And here comes the problem. How can i either pass these parameters to the 
> linker, or extract the libs out of the string?

Mathias, here is the overview of what you should do.  I expect you to find
the details in the cmake documentation for yourself.

* EXECUTE_PROCESS to run icu-config and collect its output in a cmake
variable.

* STRING to parse that output into the full path of the external library.
TARGET_LINK_LIBRARIES (below) does not need a full path, but I find that
cmake always does the right thing in that case whereas if you use the -LDIR
-licu form it won't always do the right thing (e.g., handle rpath concerns
in the build tree correctly).

* TARGET_LINK_LIBRARIES to make your target library depend on that external
library.

* Put this logic into a standard Find module, e.g., FindICU.cmake, following
the proper form documented at
http://www.cmake.org/cgi-bin/viewcvs.cgi/Modules/readme.txt?rev=1.12&root=CMake&view=log
Also have a look at 
http://www.cmake.org/cgi-bin/viewcvs.cgi/Modules/?root=CMake, especially the
Find???.cmake modules modified by Alex in the last three months to follow
the readme.txt standard.

* Once you have a FindICU.cmake that works for you and which also follows
the readme.txt standard, I would encourage you to donate it to CMake so
others can benefit from your work and possibly even improve it.

Good luck.

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
__________________________


More information about the CMake mailing list