Write sections conditionally.

Introduces some risk as it is a more complicated solution than having
fixed sections written into the CMakelists.txt files - however this is a
far cleaner solution.

The list file is only as ugly as the features used.

Hopefully, almost always the ugliness will be limited to the comments
that delimit the target output or directory output.

The files are then much cleaner so the extra test and validation effort
required are felt justified.
Flat command space + TODO note.