windows - Windows - Visual Studio 2019 - cmake - cl.exe 损坏
问题描述
我有 Visual Studio 2019,最新版本。
如果我打开 cmd 或 Visual Studio developer cmd 并cmake ../
从build_win
目录运行,我会得到以下输出:
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- The CXX compiler identification is MSVC 19.28.29914.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.18/Modules/CMakeTestCXXCompiler.cmake:59 (message):
The C++ compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: F:/Project/build_win/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/MSBuild/Current/Bin/MSBuild.exe cmTC_72b6d.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && Microsoft (R) Build Engine verze 16.9.0+5e4b48a27 pro .NET Framework
Copyright (C) Microsoft Corporation. Všechna práva vyhrazena.
Optimalizující kompilátor C/C++ společnosti Microsoft (R) verze 19.28.29914 pro procesory x64
cl /c /Zi /Wall /WX- /diagnostics:column /Od /Ob0 /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /std:c++17 /Fo"cmTC_72b6d.dir\Debug\\" /Fd"cmTC_72b6d.dir\Debug\vc142.pdb" /Gd /TP /errorReport:queue -Wextra -O3 F:\Project\build_win\CMakeFiles\CMakeTmp\testCXXCompiler.cxx
cl : command line error D8021: argument /Wextra [F:\Project\build_win\CMakeFiles\CMakeTmp\cmTC_72b6d.vcxproj]
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:12 (project)
-- Configuring incomplete, errors occurred!
See also "F:/Project/build_win/CMakeFiles/CMakeOutput.log".
See also "F:/Project/build_win/CMakeFiles/CMakeError.log".
我的 CMakeLists.txt 是这样的:
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(TORCH_DIR "f:/Project/libtorch")
message("Torch: ${TORCH_DIR}")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -O3")
set(CMAKE_BUILD_TYPE "Release")
project(TorchDemo)
add_definitions(/FI"stdint.h")
set(PROJECT_ROOT "${PROJECT_SOURCE_DIR}")
set(VSRC "${PROJECT_ROOT}/Torch")
include_directories(${VSRC}/)
list(APPEND CMAKE_PREFIX_PATH ${TORCH_DIR})
find_package(Torch CONFIG REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
message("Torch libraries: ${TORCH_LIBRARIES}")
add_executable(torch_demo ${VSRC}/main.cpp)
target_link_libraries(torch_demo "${TORCH_LIBRARIES}")
if (MSVC)
file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")
add_custom_command(TARGET torch_demo
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${TORCH_DLLS}
$<TARGET_FILE_DIR:torch_demo>)
endif (MSVC)
有什么想法有什么问题吗?如果我cl.exe
直接运行,它会运行。
解决方案
推荐阅读
- android - 电话通讯录同步
- svg - 使用 svgicons2svgfont 转换为字体时,SVG 呈现为正方形
- single-sign-on - 无需用户名和密码即可登录 Gentics Mesh UI
- c# - 过滤ICollectionView,只有N个item
- swiftui - 如何在 SwiftUI 中的 SegmentedPickerStyle 中为 Picker 提供图像和文本?
- angularjs - ui找不到加载在不同空间下的js
- javascript - JS\Node 按多个属性减少分组并汇总 JSON 数据
- android - 使用参数深度链接到另一个模块
- c# - C# - 使用子对象调用子类
- firefox - 如何使用 firefox 和 chrome 扩展执行对页面可见的脚本