Hi,
is there a built-in method to add the (complete) interface of a library to the private include directories of another target (i.e. the include path used when compiling that target)?
Example:
- lib1: non-
INTERFACE_ONLYlibrary which hasheader1.hin its interface - lib2: non-
INTERFACE_ONLYlibrary which hasheader2.hin its interface;header2.hcontains#include "header1.h" - executable: one of its
.cfiles contains#include "header2.h"; no link dependency on lib2 or lib1
Approach:
get_target_property(lib2_interface lib2 INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(executable PRIVATE ${lib2_interface})
- Would this work reliably? I mean:
- regardless of the order in which the lib1, lib2, and executable targets are defined
- transitively (pulling in also the interface of lib1 without explicitly having to specify that dependency in the executable target)
- Is there a better method to add lib2ās (and transitively also lib1ās) interface directories to the include directories used when compiling executable?
Kind regards
Ingolf