cmake_minimum_required(VERSION 3.4)

#[[
Potentially Common Utilities
#]]

# Get the Windows Version for Visual C++
macro(get_windows_version version)
    if (CMAKE_SYSTEM_VERSION)
        set(ver ${CMAKE_SYSTEM_VERSION})
        string(REGEX MATCH "^([0-9]+).([0-9])" ver ${ver})
        string(REGEX MATCH "^([0-9]+)" verMajor ${ver})
        # Check for Windows 10, b/c we'll need to convert to hex 'A'.
        if ("${verMajor}" MATCHES "10")
            set(verMajor "A")
            string(REGEX REPLACE "^([0-9]+)" ${verMajor} ver ${ver})
        endif ("${verMajor}" MATCHES "10")
        # Remove all remaining '.' characters.
        string(REPLACE "." "" ver ${ver})
        # Prepend each digit with a zero.
        string(REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ver})
        set(${version} "0x${ver}")
    endif(CMAKE_SYSTEM_VERSION)
endmacro(get_windows_version)

function(prepend var_name prefix)
    set(lst "")
    foreach(filename ${ARGN})
        list(APPEND lst "${prefix}/${filename}")
    endforeach()
    set(${var_name} "${lst}" PARENT_SCOPE)
endfunction()