I have a target which generates some code, however, I do not always want to generate the code, because it is time consuming, and causes lots of recompilation. I want to build like this:
NOGEN=true make
But CMake is thwarting me:
add_custom_target(gen_messages
if (NOT DEFINED ENV{NOGEN})
COMMAND echo "Generating messages"
COMMAND ...
...
endif()
)
It doesn't like it inside the custom target. I can't make out why. As usual, the ìf documentation does not explain. I am able to use it outside the target.
How do I do this?