Can't generate with cmake

I get this error:

PS C:\dev\cp-davinci-plugin> cmake --preset “Windows-Debug”

Preset CMake variables:

CMAKE_BUILD_TYPE=“Debug”
CMAKE_CXX_COMPILER=“cl”
CMAKE_C_COMPILER=“cl”
EPEN_AUX_CMAKE_DEBUGGING=“ON”

– The CXX compiler identification is MSVC 19.39.33520.0
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - failed
– Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe
– Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.29/Modules/CMakeTestCXXCompiler.cmake:60 (message):
The C++ compiler

"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: 'C:/dev/cp-davinci-plugin/out/build/Windows-Debug/CMakeFiles/CMakeScratch/TryCompile-3pkgzu'

Run Build Command(s): C:/ProgramData/chocolatey/bin/ninja.exe -v cmTC_21846
[1/2] C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x64\cl.exe  /nologo /TP   /DWIN32 /D_WINDOWS /EHsc  /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd /showIncludes /FoCMakeFiles\cmTC_21846.dir\testCXXCompiler.cxx.obj /FdCMakeFiles\cmTC_21846.dir\ /FS -c C:\dev\cp-davinci-plugin\out\build\Windows-Debug\CMakeFiles\CMakeScratch\TryCompile-3pkgzu\testCXXCompiler.cxx
[2/2] C:\Windows\system32\cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_21846.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_21846.dir\testCXXCompiler.cxx.obj  /out:cmTC_21846.exe /implib:cmTC_21846.lib /pdb:cmTC_21846.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
FAILED: cmTC_21846.exe
C:\Windows\system32\cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_21846.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_21846.dir\testCXXCompiler.cxx.obj  /out:cmTC_21846.exe /implib:cmTC_21846.lib /pdb:cmTC_21846.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_21846.dir\testCXXCompiler.cxx.obj /out:cmTC_21846.exe /implib:cmTC_21846.lib /pdb:cmTC_21846.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_21846.dir/intermediate.manifest CMakeFiles\cmTC_21846.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
out/build/Windows-Debug/_deps/spdlog-src/CMakeLists.txt:13 (project)

– Configuring incomplete, errors occurred!
PS C:\dev\cp-davinci-plugin>


I have tried repairing/updating vs build tools - Updating environment variables

You don’t seem to be at a developer prompt. MSVC cannot be used with just “the compiler is named cl” as it relies on environment variables to tell it where necessary headers and libraries are. That is what the developer prompt (or loading vcvarsall.bat) provides.

I ran vcvarsall but it didnt help I can put many INCLUDE and LIB variables to make this work but that would mess up with compiler loading c++ headers and other things.
Can you please help me further?

Just running vcvarsall.bat doesn’t do much (it loads the environment in a new cmd process which then exits). You need to use call vcvarsall.bat (the cmd equivalent of source some_script.sh).