Can I tell what sources / include dirs / targets are PUBLIC vs PRIVATE in target properties?

It’s possible to read the sources / include dirs / target dependencies of a target via target properties like SOURCES and LINK_LIIBRARIES. This doesn’t tell me whether these are PUBLIC or PRIVATE though. Is there a way to get this information through CMake?

Public simply means that the sources populate both the SOURCES and the INTERFACE_SOURCES properties. I’m not sure if there’s a way to retrieve the list of sources specified as public, but you could probably reconstruct it by getting the SOURCES and INTERFACE_SOURCES properties and finding the sources that are present in both.

1 Like