Add support for CMake APPEND_STRING.

Based on the work by Ben Wagner, but extended and properly tested.

REVIEW: 115095