[CMake] Providing multiple different MAJOR API versions with write_basic_package_version_file

Philip Van Hoof philip at codeminded.be
Mon Nov 4 06:32:37 EST 2019


Hello,

After Craig's very interesting presentation at CppCon 2019* I learned a
bunch of new things which I of course immediately wanted to try out**.

I read about the write_basic_package_version_file which is in
CMakePackageConfigHelpers. Craig also mentioned in the presentation
that you can have a so called API-version in the target's name. And
that for example Qt does this (Qt5Core, which has the MAJOR number 5 in
its target name).

For my target name I prefer to have the API version after a dash, like
how GLib and DBus packages do it: libglib-2.0.so.0.6200.1 on current
Ubuntu, for example in /usr/lib/x86_64-linux-gnu.

I wonder what that means for the <filename> property of
write_basic_package_version_file. In the autotools and meson world, the
usage of pkg-config files seems to indicate that the same filename
naming scheme applies to the .pc file: 

/usr/lib/x86_64-linux-gnu/pkgconfig/glib-2.0.pc

This allows me to distinguish between older MAJOR API versions of GLib
and newer MAJOR API versions of it, using FindPkgConfig***

Supposedly something similar is possible with find_package's .cmake
files as installed by write_basic_package_version_file?

How do I provide a PackageNameConfigVersion.cmake for major version 1.0
and 2.0 (the equivalent of PackageName-1.0.pc and PackageName-2.0.pc in
the pkgconfig directory)?

Kind regards,

Philip

* https://www.youtube.com/watch?v=m0DwB4OvDXk
** https://github.com/pvanhoof/dir-examples/commit/523cab5edaff99acba037218d5b95227cb2487a9
*** https://cmake.org/cmake/help/v3.15/module/FindPkgConfig.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <https://cmake.org/pipermail/cmake/attachments/20191104/1ce094ce/attachment.sig>


More information about the CMake mailing list