CMake hex2dec and dec2hex
CMake hexidecimal to decimal conversion uses the convention that 0x prefix on a number implies it’s a hexadecimal number.
Suppose CMake scripts “hex2dec.cmake”:
math(EXPR decval "0x${hexval}" OUTPUT_FORMAT DECIMAL)
message(STATUS "Hex: ${hexval} => decimal: ${decval}")running
cmake -Dhexval=14 -P hex2dec.cmakeyields:
– Hex: 14 => decimal: 20