Ahhhh… Ok, now I get it… You guys are correct, I can just add all generated sources as PRIVATE, I tried it out in my sample project.
I thought, that the #include of the header file in the MyApp.cpp file:
...
#if __has_include("my/namespace/my-header-file-4.h")
#include "my/namespace/my-header-file-4.h"
#endif
...
would not work, if the source was not declared as PUBLIC, but it does work, since in the my-lib target I am adding the include directory as PUBLIC
...
target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/generated")
...
meaning, it also ’ propagates’ to the my-app target. If I change it to PRIVATE I get
… was not declared in this scope
errors, when trying to build the my-app target
But now I am confused… Why would I ever need to add sources as PUBLIC? I guess I need to read up on that…
Thanks to both of you for your effort and the time you invest in helping!