# From: https://stackoverflow.com/a/7216542 function(JOIN VALUES GLUE OUTPUT) string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}") string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE) endfunction()