Repository: conan-io/conan

Issue:
Settings friction review
I've been experimenting with non-common settings for embedded devices and I've found a couple of issues:

1. We have to review why the CMake() build helper is raising in case it doesn't have compiler or architecture. It is very very uncomfortable to specify the settings and deleting them later for the package_id just to avoid the error. And it makes no sense. 
2. If I install a `conanfile.txt` but without specifying `os` setting, it is crashing in the settings.py validate() method. Because somehow it has the os in the fields but not in the data. 



Discussion:

Patch:
diff --git a/conans/client/build/cmake.py b/conans/client/build/cmake.py
index 2702d2b9e..3a2494873 100644
--- a/conans/client/build/cmake.py
+++ b/conans/client/build/cmake.py
@@ -115,8 +115,11 @@ class CMake(object):
             return os.environ["CONAN_CMAKE_GENERATOR"]
 
         if not self._compiler or not self._compiler_version or not self._arch:
-            raise ConanException("You must specify compiler, compiler.version and arch in "
-                                 "your settings to use a CMake generator")
+            if self._os_build == "Windows":
+                raise ConanException("You must specify compiler, compiler.version and arch in "
+                                     "your settings to use a CMake generator. You can also declare "
+                                     "the env variable CONAN_CMAKE_GENERATOR.")
+            return "Unix Makefiles"
 
         if self._compiler == "Visual Studio":
             _visuals = {'8': '8 2005',


Test patch:
diff --git a/conans/test/build_helpers/cmake_test.py b/conans/test/build_helpers/cmake_test.py
index 85d1ba227..ff1802915 100644
--- a/conans/test/build_helpers/cmake_test.py
+++ b/conans/test/build_helpers/cmake_test.py
@@ -773,6 +773,29 @@ build_type: [ Release]
         cmake = CMake(conan_file)
         self.assertIn('-T "v140"', cmake.command_line)
 
+
+    def test_missing_settings(self):
+        def instance_with_os_build(os_build):
+            settings = Settings.loads(default_settings_yml)
+            settings.os_build = os_build
+            conan_file = ConanFileMock()
+            conan_file.settings = settings
+            return CMake(conan_file)
+
+        cmake = instance_with_os_build("Linux")
+        self.assertEquals(cmake.generator, "Unix Makefiles")
+
+        cmake = instance_with_os_build("Macos")
+        self.assertEquals(cmake.generator, "Unix Makefiles")
+
+        with self.assertRaisesRegexp(ConanException, "You must specify compiler, "
+                                                     "compiler.version and arch"):
+            instance_with_os_build("Windows")
+
+        with tools.environment_append({"CONAN_CMAKE_GENERATOR": "MyCoolGenerator"}):
+            cmake = instance_with_os_build("Windows")
+            self.assertEquals(cmake.generator, "MyCoolGenerator")
+
     def test_cmake_system_version_android(self):
         with tools.environment_append({"CONAN_CMAKE_SYSTEM_NAME": "SomeSystem",
                                        "CONAN_CMAKE_GENERATOR": "SomeGenerator"}):
diff --git a/conans/test/integration/cmake_flags_test.py b/conans/test/integration/cmake_flags_test.py
index a74a320ba..2af97aeff 100644
--- a/conans/test/integration/cmake_flags_test.py
+++ b/conans/test/integration/cmake_flags_test.py
@@ -254,10 +254,13 @@ class MyLib(ConanFile):
             client = TestClient()
             client.save({"conanfile.py": conanfile % settings_line})
             client.run("install .")
-            client.run("build .", ignore_error=True)
-
-            self.assertIn("You must specify compiler, compiler.version and arch in "
-                          "your settings to use a CMake generator", client.user_io.out,)
+            error = client.run("build .", ignore_error=True)
+            if platform.system() == "Windows":
+                self.assertTrue(error)
+                self.assertIn("You must specify compiler, compiler.version and arch in "
+                              "your settings to use a CMake generator", client.user_io.out,)
+            else:
+                self.assertFalse(error)
 
     def cmake_shared_flag_test(self):
         conanfile = """