Option default value bug

I think I found a bug in cmake. I was redirected here to find out if it is really a bug.


cmake_minimum_required(VERSION 3.10)
project(test VERSION 0.0.0)
option(BITS "Bits" 64)
message(STATUS ${BITS})

First I prepared the build directory with rm -r build/*. Then I ran cmake -B build -S tree expecting to see 64 but OFF got printed instead. Does anyone have any idea why? Can you reproduce it?

If I invoke cmake with cmake -B build -S tree -DBITS=64 then it prints 64.

Tested with cmake version 3.26.4.

option is for boolean values, not number values. You should be using:

set (BITS 64 CACHE STRING "Bits")