gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 19:41:18 28 4
gpt4 key购买 nike

在撰写 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
编辑:
您还可以像这样手动设置工具集:
# Must be called before project call
set(CMAKE_GENERATOR_TOOLSET "ClangCL")

project(FOOBAR
LANGUAGES "CXX"
)

关于visual-studio - 如何在 VS2019 CMAKE 中使用 Clang-CL LLVM?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64189111/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com