I just realised that I have a lot of CMake code where the intention is to compare a variable with a value, but the value has no ““ around itself. This work as long as there is no variable with the same name, since then the value is kind of “implicitly quoted”. An example (not the most troubling for me, but easy to demonstrate):
if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
I will not have a variable named “Clang”, but if I had, the if-statement would turn out differently. I have several other cases where I would have liked if CMake could warn me about the lack of ““ around a value.
Just to investigate this, I made a small change to the function cmConditionEvaluator::GetVariableOrString() in the CMake source in file “cmConditionEvaluator.cxx”. Now it gives me warnings if an “unquoted string” is interpreted as a string. I find several cases that I want to fix, to make the code clearer and avoid the risk of accidental name collision with an unrelated variable.
I also noted that the “standard library” of CMake is not clean with my warning, so it perhaps too agressive.
I searched for an existing warning about this, but could not find any. Now I just want to know if I have interpreted the situation correctly, and that I have not missed some other way of being warned.
Johan Holmberg