Skip to content

Have export macros header include version header

Single-lib KF module example (see kio!1194 (merged) for multi-lib one)

Needs extra-cmake-modules!341 (merged)

This automatically provides the version definitions to almost all places consuming public API, given they usually also include the export macros header indirectly.


  • no more need to add an explicit include of the version header when needing access (e.g. when checking availability of some API)
  • no more need to clean up no longer needed version header includes


  • due to change each version this is another trigger for a full rebuild of consumer code on each new version (for people building KF over and over from updated repo checkouts)

The disadvantage though also is given with the current KF export headers generated with ECMGenerateExportHeader, as it injects the current version for some comparisons, so also changes each version, even when there are no changes due to any new deprecation levels. This might be something that could be looked at to improve. On the other hand no-one seems to have noticed in the last years, so it might not be that annoying. And it only affects people building KF from repo updates over and over, who, IMHO and by my own pattern, should at least once a month restart with clean build dirs anyway to not run into troubles due to outdated build artifacts.
Any automated builds on CI or packages do clean builds every time. People using the headers from packages already get full rebuilds also before, as each version comes with new filesystem timestamps (both the original headers as well as generated ones during package builds), so at least "make" is triggered to rebuild anything using those headers.

Proposing to add this automated inclusion only for KF6, so people can try to remember that only with KF6 they can rely on the version macros being magically available, and with KF5 have to always explicitly include the header as before.

Edited by Friedrich W. H. Kossebau

Merge request reports