set(my_global_string "a string value"
CACHE STRING "a description about the string variable")
set(my_global_bool TRUE
CACHE BOOL "a description on the boolean cache entry")
In case a cached variable is already defined in the cache when CMake processes the respective line (e.g. when CMake is rerun), it is not altered.
To overwrite the default, append FORCE
as the last argument:
set(my_global_overwritten_string "foo"
CACHE STRING "this is overwritten each time CMake is run" FORCE)