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")
如果当CMake处理相应的行时(例如,当CMake重新运行时)已在缓存中定义了已缓存的变量,则该变量不会更改。要覆盖默认值,请追加FORCE作为最后一个参数:
set(my_global_overwritten_string "foo" CACHE STRING "this is overwritten each time CMake is run" FORCE)