Repository: conan-io/conan
Pull request: Do not remove sh from path in the new CMake helper
Changelog: Feature: Do not remove sh from the path in the new CMake helper.
Docs: https://github.com/conan-io/docs/pull/2055

#TAGS: slow

- [x] Refer to the issue that supports this Pull Request: closes #8597
- [x] If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
- [x] I've read the [Contributing guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).
- [x] I've followed the PEP8 style guides for Python code.
- [x] I've opened another PR in the Conan docs repo to the ``develop`` branch, documenting this one. 

<sup>**Note:** By default this PR will skip the slower tests and will use a limited set of python versions. Check [here](https://github.com/conan-io/conan/blob/develop/.github/PR_INCREASE_TESTING.md) how to increase the testing level by writing some tags in the current PR body text.</sup>


Problem statement:
Remove removal of "sh" from path for MinGW in CMake
New conan.tools.cmake CMake helper contains:

```python
 if is_windows_mingw:
                with tools.remove_from_path("sh"):
                    self._conanfile.run(command)
```

This is no longer necessary, can be replaced by ``set(DCMAKE_SH="CMAKE_SH-NOTFOUND")``. Please remove it and add a red/green test for it.

Hints from issue discussion:

Commit message: Use CMAKE_SH-NOTFOUND

Patch to review:
diff --git a/conan/tools/cmake/base.py b/conan/tools/cmake/base.py
index 860892e704f..5a520f642f8 100644
--- a/conan/tools/cmake/base.py
+++ b/conan/tools/cmake/base.py
@@ -95,6 +95,7 @@ class CMakeToolchainBase(object):
             # We are going to adjust automagically many things as requested by Conan
             #   these are the things done by 'conan_basic_setup()'
             set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY ON)
+            set(CMAKE_SH "CMAKE_SH-NOTFOUND")
             # To support the cmake_find_package generators
             {% if cmake_module_path -%}
             set(CMAKE_MODULE_PATH {{ cmake_module_path }} ${CMAKE_MODULE_PATH})
diff --git a/conan/tools/cmake/cmake.py b/conan/tools/cmake/cmake.py
index 4139447819d..db43d324996 100644
--- a/conan/tools/cmake/cmake.py
+++ b/conan/tools/cmake/cmake.py
@@ -85,11 +85,7 @@ def configure(self, source_folder=None):
         is_windows_mingw = platform.system() == "Windows" and self._generator == "MinGW Makefiles"
         self._conanfile.output.info("CMake command: %s" % command)
         with chdir(build_folder):
-            if is_windows_mingw:
-                with tools.remove_from_path("sh"):
-                    self._conanfile.run(command)
-            else:
-                self._conanfile.run(command)
+            self._conanfile.run(command)
 
     def _build(self, build_type=None, target=None):
         bf = self._conanfile.build_folder
diff --git a/conans/test/functional/toolchains/cmake/test_cmake.py b/conans/test/functional/toolchains/cmake/test_cmake.py
index c59da9317a1..9452b5c1b6d 100644
--- a/conans/test/functional/toolchains/cmake/test_cmake.py
+++ b/conans/test/functional/toolchains/cmake/test_cmake.py
@@ -528,3 +528,53 @@ def build(self):
         client.run("install .")
         client.run("build .")
         self.assertIn("VALUE OF CONFIG STRING: my new value", client.out)
+
+
+@pytest.mark.skipif(platform.system() != "Windows", reason="Tests Windows MinGW")
+class TestMinGW:
+    conanfile = textwrap.dedent("""
+            from conans import ConanFile
+            from conan.tools.cmake import CMake, CMakeToolchain
+            class App(ConanFile):
+                settings = "os", "arch", "compiler", "build_type"
+                generators = "cmake_find_package_multi"
+                exports_sources = "CMakeLists.txt", "main.cpp"
+
+                def generate(self):
+                    tc = CMakeToolchain(self)
+                    tc.generate()
+
+                def build(self):
+                    cmake = CMake(self)
+                    cmake.configure()
+                    cmake.build()
+            """)
+    cmakelists = textwrap.dedent("""
+        cmake_minimum_required(VERSION 2.8)
+        project(app)
+        add_executable(app main.cpp)
+        """)
+    main_cpp = gen_function_cpp(name="main")
+
+    @pytest.mark.tool_mingw64
+    @pytest.mark.tool_cmake(version="3.15")
+    def test_mingw64(self):
+        profile = textwrap.dedent("""
+            [settings]
+            os=Windows
+            arch=x86_64
+            build_type=Release
+            compiler=gcc
+            compiler.version=4.9
+            compiler.libcxx=libstdc++
+            compiler.cppstd=98
+            """)
+        client = TestClient()
+        client.save({"conanfile.py": self.conanfile, "CMakeLists.txt": self.cmakelists,
+                     "main.cpp": self.main_cpp, "profile": profile})
+        client.run_command("where cmake")
+        print("CMAKE PATH: %s" % client.out)
+        client.run_command("cmake --version")
+        assert "cmake version 3.15" in client.out
+        client.run("create . test/1.0@ --profile profile", assert_error=True)
+        print(client.out)


Code review comments:
diff_hunk: @@ -528,3 +528,53 @@ def build(self):
         client.run("install .")
         client.run("build .")
         self.assertIn("VALUE OF CONFIG STRING: my new value", client.out)
+
+
+@pytest.mark.skipif(platform.system() != "Windows", reason="Tests Windows MinGW")
path: conans/test/functional/toolchains/cmake/test_cmake.py
text: @user1:
``TestSubsystemsCMakeBuild`` is already building very similar tests, isn't there any overlap?

@author:
Still a draft. I made another test for better isolation of the test but I will unify them to the existing MinGW ones once I figure out the cmake behavior