Content #
target_compile_definitions(<source> <INTERFACE|PUBLIC|PRIVATE> [items1...])
This target command will populate the COMPILE_DEFINITIONS property of a <source> target. Compile definitions are simply -Dname=definition flags passed to the compiler that configure the C++ preprocessor definitions.
We need to specify one of three values, INTERFACE, PUBLIC, or PRIVATE, to control which targets the property should be passed to. • PRIVATE sets the property of the source target. • INTERFACE sets the property of the destination targets. • PUBLIC sets the property of the source and destination targets.
When a property is not to be transitioned to any destination targets, set it to PRIVATE.
When such a transition is needed, go with PUBLIC.
If you’re in a situation where the source target doesn’t use the property in its implementation (.cpp files) and only in headers, and these are passed to the consumer targets, INTERFACE is the answer.
From #
Modern CMake for C++