Understanding Generator Expressions
Let's learn about generator expression evaluating a full path to the target's binary file.
We'll cover the following...
CMake builds the solution in three stages: configuration, generation, and running the build tool. Generally, we have all the required data during the configuration stage. But every once in a while, we encounter the chicken and the egg problem. For example, a target needs to know the path of a binary artifact of another target, but that information is only available after all the list files are parsed and the configuration stage is complete.
How do we deal with that kind of problem? We could create a placeholder for that information and postpone its evaluation to the next stage: the generation stage.
Generator expressions
This is what generator expressions (sometimes called genexes) do. They are built around target properties such as LINK_LIBRARIES
, INCLUDE_DIRECTORIES
, ...