[CMake] providing library information, what's the cmake way

Michael Hertling mhertling at online.de
Sun Dec 5 07:46:35 EST 2010


On 11/30/2010 05:53 AM, Kishore wrote:
> On Tuesday 23 Nov 2010 5:27:56 pm Johannes Zarl wrote:
>> Another somehow related topic seems to be import/export of targets. Should
>> a LibraryConfig.cmake or FindLibrary.cmake file create imported targets
>> for the library?
> 
> Thanks for this thread. It has helped. However, i am still not clear about the use of the export/import feature. I thought that libraries built with cmake would not need to write their Find*.cmake or *Config.cmake modules as they could simply use the EXPORT feature.

No, the file created and installed by INSTALL(EXPORT ...) - casually
denoted as a "targets file" - contains information about the targets
provided by the package. The targets are set up as "IMPORTED" in the
targets file, and the latter must be included by *Config.cmake which
is still necessary. This is meant as a more flexible alternative to
explicit paths in XXX_LIBRARIES variables, e.g.; with targets files,
XXX_LIBRARIES contains the imported targets instead of the targets'
paths, so the different build types can be handled much better at
link time. The actual paths of the imported targets are specified
by means of IMPORTED_LOCATION properties in the targets file, too.

> It would be really helpful if someone could explain the proper use of these features.

In [1,2], the machinery is explained quite well.

Regards,

Michael

[1]<http://www.cmake.org/Wiki/CMake_2.6_Notes#Exporting_from_an_Installation_Tree>
[2]<http://www.cmake.org/Wiki/CMake_2.6_Notes#Packaging_and_Exporting>


More information about the CMake mailing list