[CMake] What is the proper way to export targets that will be split into separate binary packages?
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Tue Apr 28 05:43:06 EDT 2015
On 2015-04-28 08:56+0200 Nils Gladitz wrote:
> On 04/28/2015 01:20 AM, Alan W. Irwin wrote:
>> On 2015-04-24 12:33-0700 Alan W. Irwin wrote:
>>
>> This should be a pretty common issue on Linux since it is quite
>> typical there that downstream packaging splits up binary results into
>> different packages. Therefore, I assume there is a CMake solution to
>> this issue, and I would appreciate those who know that solution to
>> speak up.
>
> I'd go with what Alex suggested in his reply.
>
> In effect it is what e.g. Qt5 does (though they don't use cmake to generate
> the exports obviously and they provide additional package configuration files
> which you can omit).
>
> The umbrella configuration file can use the component specification given to
> find_package() to iterate over the required target export files.
>
> There is an example of this here (scroll down to "If COMPONENTS are specified
> when the downstream uses[...]"):
@Nils: the origin of the code right below "If COMPONENTS..." is not
clear. Is that code that should be supplied by a package creator or code that
should be implemented by every find_package user? And if it should be
supplied by a package creator, does the install(EXPORT...) signature
generate that code automatically, does one of the helper functions
that are available generate that code, or do I (as package creator)
have to supply that code some other way?
>
> http://www.cmake.org/cmake/help/v3.2/manual/cmake-packages.7.html#creating-packages
@Alex: Sorry I missed your reply until now.
@Alex or Nils:
The problem with the URL provided by Nils is only one library is used
in the example so I don't understand exactly what you guys are
suggesting for the multiple library/component case.
For example, are you recommending
install(TARGETS plplot1 EXPORT export_plplot ...)
[...]
install(TARGETS plplotN EXPORT export_plplot ...)
for N installed libraries followed by
install(EXPORT export_plplot DESTINATION ${LIB_DIR}/cmake/plplot)
? That is the current pattern I am using with one overall export name
called "export_plplot". Or would you recommend this different pattern
install(TARGETS plplot1 EXPORT export_plplot1 ...)
install(EXPORT export_plplot1 DESTINATION ${LIB_DIR}/cmake/plplot)
[...]
install(TARGETS plplotN EXPORT export_plplotN ...)
install(EXPORT export_plplotN DESTINATION ${LIB_DIR}/cmake/plplot)
(i.e., N pairs of install(TARGETS...) install(EXPORT...) signatures
with each pair having a unique export name)?
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); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); 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