Repository: conan-io/conan

Issue:
Conan client crash with CMake and removed settings
When I have a conanfile where I remove some settings:

```
    settings =  {"os": ["Linux", "Macos"],
             "compiler": None,
             "arch": None}
```

If I use the "CMake" class in build...:

```
cmake = CMake(self.settings)
```

It crashes because CMake class makes comparations with settings that I don't have, and its checked that this setting exists:

```
if self._settings.os == "Windows":
```

I think we should "cast" to str the settings in this case or something like that.



Discussion:

Resolving patch:
diff --git a/conans/client/cmake.py b/conans/client/cmake.py
--- a/conans/client/cmake.py
+++ b/conans/client/cmake.py
@@ -26,27 +26,31 @@ def generator(self):
             raise ConanException("You must specify compiler, compiler.version and arch in "
                                  "your settings to use a CMake generator")
 
-        if self._settings.compiler == "Visual Studio":
+        operating_system = str(self._settings.os) if self._settings.os else None
+        compiler = str(self._settings.compiler) if self._settings.compiler else None
+        arch = str(self._settings.arch) if self._settings.arch else None
+
+        if compiler == "Visual Studio":
             base = "Visual Studio %s" % self._settings.compiler.version
-            if self._settings.arch == "x86_64":
+            if arch == "x86_64":
                 return base + " Win64"
-            elif self._settings.arch == "arm":
+            elif arch == "arm":
                 return base + " ARM"
             else:
                 return base
 
-        if self._settings.os == "Windows":
-            if self._settings.compiler == "gcc":
+        if operating_system == "Windows":
+            if compiler == "gcc":
                 if self._settings.compiler.version == "4.9":
                     return "Unix Makefiles"
                 return "MinGW Makefiles"
-            if self._settings.compiler in ["clang", "apple-clang"]:
+            if compiler in ["clang", "apple-clang"]:
                 return "MinGW Makefiles"
-        if self._settings.os == "Linux":
-            if self._settings.compiler in ["gcc", "clang", "apple-clang"]:
+        if operating_system == "Linux":
+            if compiler in ["gcc", "clang", "apple-clang"]:
                 return "Unix Makefiles"
-        if self._settings.os == "Macos":
-            if self._settings.compiler in ["gcc", "clang", "apple-clang"]:
+        if operating_system == "Macos":
+            if compiler in ["gcc", "clang", "apple-clang"]:
                 return "Unix Makefiles"
 
         raise ConanException("Unknown cmake generator for these settings")
@@ -63,7 +67,7 @@ def is_multi_configuration(self):
     @property
     def command_line(self):
         return '-G "%s" %s %s %s -Wno-dev' % (self.generator, self.build_type,
-                                     self.runtime, self.flags)
+                                              self.runtime, self.flags)
 
     @property
     def build_type(self):
@@ -89,9 +93,9 @@ def build_config(self):
 
     @property
     def flags(self):
-        op_system = self._settings.os
-        arch = self._settings.arch
-        comp = self._settings.compiler
+        op_system = str(self._settings.os) if self._settings.os else None
+        arch = str(self._settings.arch) if self._settings.arch else None
+        comp = str(self._settings.compiler) if self._settings.compiler else None
         comp_version = self._settings.compiler.version
 
         flags = []


Test patch:
diff --git a/conans/test/cmake_test.py b/conans/test/cmake_test.py
--- a/conans/test/cmake_test.py
+++ b/conans/test/cmake_test.py
@@ -37,3 +37,22 @@ def loads_default_test(self):
                          '-DCONAN_COMPILER_VERSION="4.8" -DCONAN_CXX_FLAGS=-m32 '
                          '-DCONAN_SHARED_LINK_FLAGS=-m32 -DCONAN_C_FLAGS=-m32 -Wno-dev',
                          cmake.command_line)
+
+    def deleted_os_test(self):
+        partial_settings = """
+os: [Linux]
+arch: [x86_64]
+compiler:
+    gcc:
+        version: ["4.9"]
+build_type: [ Release]
+"""
+        settings = Settings.loads(partial_settings)
+        settings.os = "Linux"
+        settings.compiler = "gcc"
+        settings.compiler.version = "4.9"
+        settings.arch = "x86_64"
+
+        cmake = CMake(settings)
+        self.assertEqual('-G "Unix Makefiles"   -DCONAN_COMPILER="gcc" '
+                         '-DCONAN_COMPILER_VERSION="4.9" -Wno-dev', cmake.command_line)