I have Visual Studio 2019, latest build.
If I open cmd or Visual Studio developer cmd and run cmake ../
from build_win
directory I got this output:
-- 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".
My CMakeLists.txt is this:
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)
Any ideas what is wrong? If I run cl.exe
directly, it runs.