Id like to generate a .h file containing code dependent on an if clause set in the input file of the configure_file.
if (VAR)
generate this line;
else()
generate that line;
endif()
As for now, Im getting in the .h code all of the above lines generated.
Is there a way to generate only specific lines, either of the if() or of the else() from the input file? Or is there any other way except for the configure_file to this?
The way that CMake code works, this would involve running the top-level command parser over the input file. That parser is not very robust to non-CMake code, so some way of encoding what is something that configure_file should look at and ignore is a tough problem. Consider:
if (bar)
if (foo)
@expand_a@
else ()
@expand_b@
endif ()
endif ()
Give this to configure_file. Is if (bar) something it should care about or something for configure_file? How about if (foo)? While it’d be nice, it’s just never going to be feasible, sorry.