[CMake] What is the proper way to export targets that will be split into separate binary packages?
Alexander Neundorf
a.neundorf-work at gmx.net
Sat Apr 25 16:14:14 EDT 2015
On Friday, April 24, 2015 12:33:50 Alan W. Irwin wrote:
> 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?
IIRC putting the targets which will end up in separate packages should be put
into separate exports.
To use everything later on using one find_package() call, you probably need
one "umbrella" config file.
Alex
More information about the CMake
mailing list