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

Feature/auto compiler cl exe #16875

Merged
merged 5 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions conan/tools/cmake/toolchain/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,12 @@ def context(self):
# To set CMAKE_<LANG>_COMPILER
if comp in compilers_by_conf:
compilers[lang] = compilers_by_conf[comp]
compiler = self._conanfile.settings.get_safe("compiler")
if compiler == "msvc" and "Ninja" in str(self._toolchain.generator):
# None of them defined, if one is defined by user, user should define the other too
if "c" not in compilers_by_conf and "cpp" not in compilers_by_conf:
compilers["C"] = "cl"
compilers["CXX"] = "cl"
return {"compilers": compilers}


Expand Down
6 changes: 6 additions & 0 deletions conan/tools/gnu/autotoolstoolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ def environment(self):
# https://github.com/conan-io/conan/issues/13780
compiler = unix_path(self._conanfile, compiler)
env.define(env_var, compiler)
compiler_setting = self._conanfile.settings.get_safe("compiler")
if compiler_setting == "msvc":
# None of them defined, if one is defined by user, user should define the other too
if "c" not in compilers_by_conf and "cpp" not in compilers_by_conf:
env.define("CC", "cl")
env.define("CXX", "cl")

env.append("CPPFLAGS", ["-D{}".format(d) for d in self.defines])
env.append("CXXFLAGS", self.cxxflags)
Expand Down
3 changes: 2 additions & 1 deletion test/functional/toolchains/cmake/test_cmake_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ def test_cmake_toolchain_cmake_vs_debugger_environment():
f"$<$<CONFIG:Release>:{release_bindir}>" \
f"$<$<CONFIG:MinSizeRel>:{minsizerel_bindir}>;%PATH%"
assert debugger_environment in toolchain


@pytest.mark.tool("cmake")
def test_cmake_toolchain_cmake_vs_debugger_environment_not_needed():
client = TestClient()
Expand All @@ -243,7 +245,6 @@ def test_cmake_toolchain_cmake_vs_debugger_environment_not_needed():
assert "CMAKE_VS_DEBUGGER_ENVIRONMENT" not in toolchain



@pytest.mark.tool("cmake")
def test_cmake_toolchain_multiple_user_toolchain():
""" A consumer consuming two packages that declare:
Expand Down
1 change: 0 additions & 1 deletion test/functional/toolchains/gnu/autotools/test_win_bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def test_autotools_bash_complete():
[conf]
tools.microsoft.bash:subsystem=msys2
tools.microsoft.bash:path=bash
tools.build:compiler_executables={{"c": "cl", "cpp": "cl"}}
""")

main = gen_function_cpp(name="main")
Expand Down
2 changes: 0 additions & 2 deletions test/functional/toolchains/gnu/test_v2_autotools_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ def test_msys2_autotools_windows(self):
[conf]
tools.microsoft.bash:subsystem=msys2
tools.microsoft.bash:path=bash
tools.build:compiler_executables={"c": "cl", "cpp": "cl"}
""")
c.save({"msys2": msys2})
# FIXME: Need to deactivate test_package because AutotoolsDeps doesn't work in Win
Expand All @@ -369,7 +368,6 @@ def test_msys2_autotools_exe_windows(self):
[conf]
tools.microsoft.bash:subsystem=msys2
tools.microsoft.bash:path=bash
tools.build:compiler_executables={"c": "cl", "cpp": "cl"}
""")
c.save({"msys2": msys2})
c.run("create . -pr=msys2")
Expand Down