[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
Mon Apr 27 19:20:45 EDT 2015


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.

> The Fedora packager of PLplot is having trouble splitting installed
> results into separate binary packages because of the way that PLplot
> currently exports its targets.  What steps do we have to do to make
> life easier for him?
>
> Here is the typical code we use now to export our targets.
>
> # Done only once
> install(EXPORT export_plplot DESTINATION ${LIB_DIR}/cmake/plplot)
>
> # Done for each different PLplot library target we want to export
> install(TARGETS <targetname>
>  EXPORT export_plplot
>  ARCHIVE DESTINATION ${LIB_DIR}
>  LIBRARY DESTINATION ${LIB_DIR}
>  RUNTIME DESTINATION ${BIN_DIR}
>  )
>
> # Done for each different PLplot executable target we want to export
> install(TARGETS <targetname>
>  EXPORT export_plplot
>  DESTINATION ${BIN_DIR}
>  )
>
> As a result of these commands, $prefix/lib/cmake/plplot contains
> three files:
>
> export_plplot-noconfig.cmake,  export_plplot.cmake,  and plplotConfig.cmake
>
> I can find no reference to the noconfig variant, but from the
> documentation, find_package(plplot) in Config mode will find
> plplotConfig.cmake which in turn includes export_plplot.cmake which
> has CMake logic that loops over _every_ exported target.
>
> For a completely separate build system (for our installed examples)
> we import all these targets using
>
> find_package(plplot)
>
> and that works well for individual use of PLplot where nothing is
> split out from the installation.
>
> However, that command does not work well for binary packagers of
> PLplot since those packagers generally split the installed files into
> a bunch of different binary packages (typically a core package and
> optional additional packages to add extra features to the core
> package).  So if the Fedora packager, for example, splits out the
> octave component of PLplot into a separate binary package, then when
> that package is not installed, find_package(plplot) errors out (as a
> result of that loop over all exported targets) with
>
> CMake Error at /usr/lib64/cmake/plplot/export_plplot.cmake:163 (message):
>  The imported target "plplot_octave" references the file
>
>     "/usr/lib64/octave/site/oct/x86_64-redhat-linux-gnu/plplot_octave.oct"
>
>  but this file does not exist.  [...]
>
> What changes to the above export procedure and/or find_package(plplot ... ) 
> command are recommended so that find_package(plplot ....) just works when 
> some split PLplot binary packages are not installed?
>
> 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
> __________________________
> -- 
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more 
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>

__________________________
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