Preparation before building c cpp model

We have a build file that mainly generate some source code and then compiles a big c/cpp model. We are using plugin ‘c’ and ‘cpp’.
At configuration time, if there is no source in the folder yet, the compilation tasks are not created so when times come to build, some tasks are missing even though the code is present at that moment.
To avoid the problem, we are calling two separate gradle entrypoints, one for the code generation, one for the build.
Is there any way to be able to do that in one gradle call? A way to tell the c plugin to reevaluate without having a different gradle instance?

I have seen through my research that there is a new cpp-application plugin but will I be stuck with the same problem with that plugin?

Cheers