CMake’s top-level parser still needs to be able to determine scoping which means being able to see all function, macro, if, while, and foreach commands with their corresponding closing commands before actually executing anything. I don’t see the C preprocessor macro being able to make half-blocks as a benefit so I’m happy this doesn’t work . But this is really a side-effect of macros being runtime-expansions.
One problem case I don’t know how to possibly handle:
foreach (func IN …)
myfunction("${func}")
endforeach ()
I’d just use function here. What is mock() gaining you here?
I was more referring to the preprocessor not allowing you to make new #if statements that it actually sees. Sure, you can stamp out whatever C you want (because it doesn’t actually care about C at all beyond the constant folding specification), but you can’t stamp out C preprocessor blocks with macros. That is what you’re asking for here.