Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not remove sh from path in the new CMake helper #8625

Merged
merged 13 commits into from Mar 23, 2021
1 change: 1 addition & 0 deletions conan/tools/cmake/base.py
Expand Up @@ -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})
Expand Down
6 changes: 1 addition & 5 deletions conan/tools/cmake/cmake.py
Expand Up @@ -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
Expand Down
50 changes: 50 additions & 0 deletions conans/test/functional/toolchains/cmake/test_cmake.py
Expand Up @@ -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")
danimtb marked this conversation as resolved.
Show resolved Hide resolved
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)