You can find Ken Martin's partial answer in a message from the CMake mailing list:
Regarding the general question of functions that return values, it can be done, but these are slightly larger changes. Functions and commands look the same (and should act the same IMO) to the people using them. Therefore, we are talking about commands that return values. This is basically just a syntax problem. Right now we have
command(arg arg arg )
to support return values โโwe need something that could handle
command (arg command2(arg arg) arg arg )
or in your case
if(assertdef(foo))
or in another case
set(foo get_property( ))
etc .. It gets into the parser and argument processing in CMake, but I think that it can be done. I think I'm not sure that we should do this. Discover opinions.
source share