[Cpp] Use target_include_dirs for cmake targets#4661
Conversation
Signed-off-by: Nick Nobles <nicholas_nobles@intuit.com>
|
Hi @mike-lischke, |
|
Sorry, I don't know enough about cmake to validate the changes. |
|
Thanks for responding @mike-lischke Would this be enough to help you validate? Or is there someone else that I could request a review from that might have more cmake knowledge? |
|
Thanks for providing that test repo, it helps to understand. @parrt I think this PR can be merged. |
|
This does seem to create some wierd artifacts where the location of the includes is actually in the wrong place Here is one issue report in nix: NixOS/nixpkgs#379757 it seems like the dev component (with the includes) ends up being installed where the library is installed, so the generated I don't know enough cmake to make sense of it, but maybe @njnobles does ? |
Use target_include_dirs to attach include directories to targets. This allows setting include directories for the
INSTALL_INTERFACEwhich will get exported intoantlr4-targets.cmake.antlr4-targets.cmakewill now have anINTERFACE_INCLUDE_DIRECTORIESproperty set like so:When downstream users pull in antlr4-runtime using
find_package(antlr4-runtime), the imported targetsantlr4_staticandantlr4_sharedwill automatically pick up the appropriate include directories instead of needing to manually useANTLR4_INCLUDE_DIR.