1# Converts a version such as 1.2.255 to 0x0102ff 2function(HexVersion version_hex_var major minor patch) 3 math(EXPR version_dec "${major} * 256 * 256 + ${minor} * 256 + ${patch}") 4 set(version_hex "0x") 5 foreach(i RANGE 5 0 -1) 6 math(EXPR num "(${version_dec} >> (4 * ${i})) & 15") 7 string(SUBSTRING "0123456789abcdef" ${num} 1 num_hex) 8 set(version_hex "${version_hex}${num_hex}") 9 endforeach() 10 set(${version_hex_var} "${version_hex}" PARENT_SCOPE) 11endfunction() 12