Replace "\n" -> ";" based line splitting with a while loop.

Changing characters around is generally just unreliable with large
strings. This technique tends to avoid bugs in CMake.