Cannot restore default (undefined?) state of CMAKE_BUILD_TYPE's STRINGS property
In ccmake 3.5.1 (on Ubuntu 16.04), the following code prints ''
when executed in a fresh build directory, implying that either CMAKE_BUILD_TYPE
's STRINGS
property is undefined by default, or that it is set to the empty string by default:
get_property(v CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS)
message("'${v}'")
If you execute the following:
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "")
and then try to edit CMAKE_BUILD_TYPE
in ccmake, it causes a segmentation fault. Logically speaking, it makes sense that the user should not be able to set CMAKE_BUILD_TYPE
when the STRINGS
property is empty, but it's not useful to allow developers to create CACHE variables that can't be set, and ccmake should never segfault. So as far as I can tell, there is no way to programmatically restore the default state of the property.
The inability to restore it prevents the use case in which a developer would like to change the STRINGS
property when a certain condition holds, and restore it to its default value when that condition ceases to hold. E.g. in my case, I would like to restrict the STRINGS
property to "Debug;RelWithDebInfo"
when my users enable support for Google Breakpad, and restore the default value of the property when they disable Breakpad support.
The only workarounds I'm aware of are:
- Don't change the
STRINGS
property. Interrupt the configuration process with an error message when the user selects an invalid build configuration. This is acceptable, but not ideal. - Do change the
STRINGS
property, and interrupt the configuration process with an error message when the default value ofSTRINGS
needs to be restored. The message should tell them to do one of the following:- remove the
CMAKE_BUILD_TYPE-STRINGS:INTERNAL=
line from their CMakeCache.txt file; - clean their build directory;
- create a new build directory.
- remove the