[build] Fix interface include directories for imported targets #342
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some versions of CMake (can't figure out exactly which, but some definitely do) don't implicitly add an
INTERFACE_INCLUDE_DIRECTORIES
property toIMPORTED
targets present in generated*Targets.cmake
CMake configs.Specifying
INCLUDES DESTINATION include
in allinstall
calls for exported targets ensures this property is always present, and fixes cases where linking to imported targets doesn't add the correct include directories.This PR also fixes an annoying issue where downstream projects would fail to include KenLM headers that transitively included other Kenlm headers (i.e.
lm/model.hh
) — this was because the installed header dir would beinclude
, but headers would be relative toinclude/kenlm
but placed insideinclude
. Addinginclude/kenlm
to theINSTALL_INTERFACE
for all exported targets ensures downstream projects can use theirIMPORTED
Kenlm targets alone without needing to add hacks to fix include directories.cc @padentomasello, @andresy, @vineelpratap, @syhw, @tlikhomanenko