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

CMAKE_MAKE_PROGRAM for mingw #10770

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion conan/tools/cmake/toolchain/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,9 @@ class GenericSystemBlock(Block):
{% if build_type %}
set(CMAKE_BUILD_TYPE "{{ build_type }}" CACHE STRING "Choose the type of build." FORCE)
{% endif %}
{% if cmake_make_program %}
set(CMAKE_MAKE_PROGRAM "{{ cmake_make_program }}")
{% endif %}
""")

def _get_toolset(self, generator):
Expand Down Expand Up @@ -723,6 +726,11 @@ def _get_compiler(self, generator):

return compiler_c, compiler_cpp, compiler_rc

def is_mingw(self):
is_win = self._conanfile.settings.get_safe("os") == "Windows"
is_gcc = self._conanfile.settings.get_safe("compiler") == "gcc"
return is_gcc and is_win

def context(self):
# build_type (Release, Debug, etc) is only defined for single-config generators
generator = self._toolchain.generator
Expand All @@ -736,6 +744,11 @@ def context(self):

system_name, system_version, system_processor = self._get_cross_build()

cmake_make_program = self._conanfile.conf.get("tools.gnu:make_program",
lasote marked this conversation as resolved.
Show resolved Hide resolved
default=None) if self.is_mingw() else None
if cmake_make_program:
cmake_make_program = cmake_make_program.replace("\\", "/")

return {"compiler": compiler,
"compiler_rc": compiler_rc,
"compiler_cpp": compiler_cpp,
Expand All @@ -744,7 +757,8 @@ def context(self):
"build_type": build_type,
"cmake_system_name": system_name,
"cmake_system_version": system_version,
"cmake_system_processor": system_processor}
"cmake_system_processor": system_processor,
"cmake_make_program": cmake_make_program}


class OutputDirsBlock(Block):
Expand Down
18 changes: 17 additions & 1 deletion conans/test/unittests/tools/cmake/test_cmaketoolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
def conanfile():
c = ConanFile(Mock(), None)
c.settings = "os", "compiler", "build_type", "arch"
c.initialize(Settings({"os": ["Windows"],
c.initialize(Settings({"os": ["Windows", "Linux"],
"compiler": {"gcc": {"libcxx": ["libstdc++"]}},
"build_type": ["Release"],
"arch": ["x86"]}), EnvValues())
Expand All @@ -32,6 +32,22 @@ def conanfile():
return c


def test_cmake_make_program(conanfile):
toolchain = CMakeToolchain(conanfile)
content = toolchain.content
assert 'set(CMAKE_MAKE_PROGRAM' not in content
conanfile.conf.define("tools.gnu:make_program", "c:\\mymake")

toolchain = CMakeToolchain(conanfile)
content = toolchain.content
assert 'set(CMAKE_MAKE_PROGRAM "c:/mymake")' in content

conanfile.settings.os = "Linux"
toolchain = CMakeToolchain(conanfile)
content = toolchain.content
assert 'set(CMAKE_MAKE_PROGRAM' not in content


def test_cmake_toolchain(conanfile):
toolchain = CMakeToolchain(conanfile)
content = toolchain.content
Expand Down