如何在VS2019 CMAKE中使用Clang-CL LLVM?

如何解决如何在VS2019 CMAKE中使用Clang-CL LLVM?

在撰写本文时,clang的Visual Studio用户手册中包含以下文档:

cmake -G"Visual Studio 2017" -T LLVM ..

这不起作用。

我从cmake收到一条错误消息:

CMake Error at CMakeLists.txt:3 (project):
  Failed to run MSBuild command:

    C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe

  to get the value of VCTargetsPath:

    Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET Framework
    copyright (C) Microsoft Corporation. All rights reserved.

    Build started 10/3/2020 5:06:06 PM.
    Project "D:\Github\glfw\build\CMakeFiles\3.18.1\VCTargetsPath.vcxproj" on node 1 (default targets).
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(411,5): error MSB8020: The build tools for LLVM99 (Platform Toolset = 'LLVM99') cannot be found. To build using the LLVM99 build tools,please install LLVM99 build tools.  Alternatively,you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution,and then selecting "Retarget solution". [D:\Github\glfw\build\CMakeFiles\3.18.1\VCTargetsPath.vcxproj]
    Done Building Project "D:\Github\glfw\build\CMakeFiles\3.18.1\VCTargetsPath.vcxproj" (default targets) -- Failed.

    Build Failed.

    "D:\Github\glfw\build\CMakeFiles\3.18.1\VCTargetsPath.vcxproj" (default target) (1) ->
    (PrepareForBuild target) ->
on,and then selecting "Retarget solution". [D:\Github\glfw\build\CMakeFiles\3.18.1\VCTargetsPath.vcxproj]

        0 Warning(s)
        1 Error(s)

    Time Elapsed 00:00:00.11


  Exit code: 1



-- Configuring incomplete,errors occurred!
See also "D:/Github/glfw/build/CMakeFiles/CMakeOutput.log".

解决方法

这不适用于VS2019。在vs2019中,您必须将工具集指定为 ClangCL 。 据我所知,该更改未记录在任何地方。 我只能通过反复试验找出答案。

cmake -G"Visual Studio 2019" -T ClangCL ..

这是您将获得的输出。

PS D:\Github\glfw> cmake -S . -B build -T ClangCl
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The C compiler identification is Clang 10.0.0 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE  
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- Using Win32 for window creation
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Github/glfw/build

这是它的样子:

enter image description here

,

https://cmake.org/cmake/help/v3.18/manual/cmake.1.html

中所述
-T <toolset-spec>

    Toolset specification for the generator,if supported.

Visual 2017不支持Clang / LLVM:
https://docs.microsoft.com/cpp/build/clang-support-msbuild?view=vs-2017

对于Visual Studio 2019,您需要使用clang-clhttps://docs.microsoft.com/cpp/build/clang-support-msbuild?view=vs-2019

如果要查看受支持的生成器:
https://cmake.org/cmake/help/v3.18/manual/cmake-generators.7.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?