Skip to content

install(EXPORT): Add mode to generate pkg-config files

Adds basic pkg-config export mode. Usage:

install(EXPORT MyExport
  CMAKE_CONFIG NAMESPACE MyNamespace:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MyPackage
  PKG_CONFIG NAMESPACE MyNamespace- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)

As an additional test, I recursively compare all the generated .cmake files in <binary dir>/Tests between this and the master branches.

Questions:

TODO for the pkg-config generator:

  • PIC mode
  • reject targets with non-empty INTEFACE_SOURCES
  • does build export generator make much sense? Sort of done moving all the generation functions to cmExportUtility, so that the build time generator can be trivially implemented later on.
  • EXPORT_LINK_INTERFACE_LIBRARIES (ExportOld)
  • Do we need private dependencies to be exported ("Requires.private" pkg-config property)?
  • link names for static libraries
  • Fix export generators printing (incorrect) backtraces from target declarations.

Issue: #22621

Edited by Brad King

Merge request reports