
  ## match replace with easier syntax 
  ## $0-$9 is replaces with the corresponding regex match group
  function(regex_match_replace match replace)
    set(CMAKE_MATCH_0)
    set(CMAKE_MATCH_1)
    set(CMAKE_MATCH_2)
    set(CMAKE_MATCH_3)
    set(CMAKE_MATCH_4)
    set(CMAKE_MATCH_5)
    set(CMAKE_MATCH_6)
    set(CMAKE_MATCH_7)
    set(CMAKE_MATCH_8)
    set(CMAKE_MATCH_9)
    if("${ARGN}" MATCHES "${match}")
      if(replace)
        set(result "${replace}")
        foreach(i RANGE 0 9)
          string(REPLACE "$${i}" "${CMAKE_MATCH_${i}}" result "${result}")
        endforeach()
        return_ref(result)
      endif()
    endif() 
    return()
  endfunction()