Skip to content

Commit

Permalink
Do not remove sh from path in the new CMake helper (#8625)
Browse files Browse the repository at this point in the history
* Do not remove sh from path in the new CMake helper

* add specific test

* assert cmake version

* print cmake path

* Update conans/test/functional/toolchains/cmake/test_cmake.py

* use default cmake 3.15

* mark cmake version

* use default cmake

* force cmake 3.15

* Use CMAKE_SH-NOTFOUND

* test cmake only

* add cmd line param and unify test
  • Loading branch information
danimtb committed Mar 23, 2021
1 parent 538c355 commit 37343e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 4 additions & 6 deletions conan/tools/cmake/cmake.py
Expand Up @@ -79,17 +79,15 @@ def configure(self, source_folder=None):
self._conanfile.package_folder.replace("\\", "/"),
source)

if platform.system() == "Windows" and self._generator == "MinGW Makefiles":
arg_list += ' -DCMAKE_SH="CMAKE_SH-NOTFOUND"'

generator = '-G "{}" '.format(self._generator) if self._generator else ""
command = "%s %s%s" % (self._cmake_program, generator, arg_list)

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
Expand Down
2 changes: 2 additions & 0 deletions conans/test/functional/toolchains/cmake/test_cmake.py
Expand Up @@ -272,6 +272,7 @@ def _verify_out(marker=">>"):
@parameterized.expand([("Debug", "libstdc++", "4.9", "98", "x86_64", True),
("Release", "libstdc++", "4.9", "11", "x86_64", False)])
@pytest.mark.tool_mingw64
@pytest.mark.tool_cmake(version="3.15")
def test_toolchain_mingw_win(self, build_type, libcxx, version, cppstd, arch, shared):
# FIXME: The version and cppstd are wrong, toolchain doesn't enforce it
settings = {"compiler": "gcc",
Expand All @@ -287,6 +288,7 @@ def test_toolchain_mingw_win(self, build_type, libcxx, version, cppstd, arch, sh
self.assertIn("The C compiler identification is GNU", self.client.out)
self.assertIn('CMake command: cmake -G "MinGW Makefiles" '
'-DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake"', self.client.out)
assert '-DCMAKE_SH="CMAKE_SH-NOTFOUND"' in self.client.out

def _verify_out(marker=">>"):
cmake_vars = {"CMAKE_GENERATOR_PLATFORM": "",
Expand Down

0 comments on commit 37343e9

Please sign in to comment.