Also moves helper functions into a module file and replaces JOIN generator expressions with list(TRANSFORM) commands in order to get the correct sources list at the configure stage.