[CMake] convert variable from hex to integer
Olaf Peter
ope-devel at gmx.de
Fri Sep 19 07:58:49 EDT 2008
Hi,
for a generated version header I need to convert a given hex to an
integer. I've wrote:
set(RELEASE_LEVEL_ALPHA 0xA) # For internal use
set(RELEASE_LEVEL_BETA 0xB) # For internal use
set(RELEASE_LEVEL_GAMMA 0xC) # For release candidates
set(RELEASE_LEVEL_FINAL 0xF) # For final release
set(VERSION_MAJOR 0)
set(VERSION_MINOR 1)
set(VERSION_MICRO 0)
set(RELEASE_LEVEL ${RELEASE_LEVEL_ALPHA})
set(RELEASE_SERIAL 0)
in CMakeLists.txt and in version.h.cmake:
enum {
MAJOR = (@VERSION_MAJOR@ << 24),
MINOR = (@VERSION_MINOR@ << 16),
MICRO = (@VERSION_MICRO@ << 8),
RELEASE_LEVEL = (@RELEASE_LEVEL@ << 4),
RELEASE_SERIAL = (@RELEASE_SERIAL@ << 0),
VERSION = MAJOR | MINOR | MICRO | RELEASE_LEVEL |
RELEASE_SERIAL
};
which results into:
enum {
MAJOR = (0 << 24),
MINOR = (1 << 16),
MICRO = (0 << 8),
RELEASE_LEVEL = (0xA << 4),
RELEASE_SERIAL = (0 << 0),
VERSION = MAJOR | MINOR | MICRO | RELEASE_LEVEL |
RELEASE_SERIAL
};
The 0xA doesn't compile.
Thanks,
Olaf
More information about the CMake
mailing list