如何在MSBuild中使用Clang编译器? [英] How to use Clang compiler with MSBuild?

查看:236
本文介绍了如何在MSBuild中使用Clang编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试一些通常在Windows上使用Microsoft C ++编译的项目,而改为使用clang编译它们.

I'm trying to take a couple of projects normally compiled on Windows with Microsoft C++ and compile them with clang instead.

从好的方面来说,有clang-cl.exe可以替代cl.exe.但是,即使将clang-cl.exe作为cl.exe复制到当前目录中,msbuild在某些情况下仍会调用Microsoft的cl.exe.

On the upside, there exists clang-cl.exe which is designed to be a drop-in replacement for cl.exe. However, even when I copy clang-cl.exe into the current directory as cl.exe, msbuild still in some cases calls Microsoft's cl.exe.

是否有一种方法可以告诉msbuild'在这里,在执行Task CL时,使用此cl.exe而不是通常的cl.exe'吗? msbuild的命令行选项在该方向上不包含任何明显的内容.

Is there a way to tell msbuild 'here, when executing Task CL, use this cl.exe instead of the usual one'? msbuild's command line options don't contain anything obvious in that direction.

还有,有一种方法可以告诉它为cl提供或覆盖命令行参数而不更改项目文件吗?

Also, is there a way to tell it to supply or override command line parameters for cl without changing the project file?

推荐答案

从命令行或项目文件都很容易做到.您需要配置的属性是$(CLToolExe)$(CLToolPath).

This is easy to do from either command line or project file. The properties you need to configure are $(CLToolExe) and $(CLToolPath).

从命令行:

msbuild MyProj.vcxproj /p:CLToolExe=clang-cl.exe /p:CLToolPath=c:\whatever\path\to\the\tool

或者,在您的.vcxproj文件中:

Alternatively, inside your .vcxproj file:

<PropertyGroup>
  <CLToolExe>clang-cl.exe</CLToolExe>
  <CLToolPath>c:\whatever\path\to\the\tool</CLToolPath>
</PropertyGroup>

如果直接在.vcxproj文件中调用任务CL,而不仅仅是依赖于公共目标,则只需设置CL任务的相应参数ToolExeToolPath.

If you are calling task CL directly inside your .vcxproj file, as opposed to just relying on common targets, just set corresponding parameters ToolExe and ToolPath of the CL task.

这篇关于如何在MSBuild中使用Clang编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆