How do I make MSVC compiler work with CMake?

42 Views Asked by At
[main] Configuring project: Computer Vision 
[proc] Executing command: "C:\Users\home\OneDrive\Documents\CODE STUFF\cmake\bin\cmake.exe" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE "-SC:/Users/home/OneDrive/Documents/CODE STUFF/C++/Computer Vision" "-Bc:/Users/home/OneDrive/Documents/CODE STUFF/C++/Computer Vision/build" -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is MSVC 19.39.33523.0
[cmake] -- The CXX compiler identification is MSVC 19.39.33523.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - failed
[cmake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x86/cl.exe
[cmake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x86/cl.exe - broken
[cmake] CMake Error at C:/Users/home/OneDrive/Documents/CODE STUFF/cmake/share/cmake-3.29/Modules/CMakeTestCCompiler.cmake:67 (message):
[cmake]   The C compiler
[cmake] 
[cmake]     "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x86/cl.exe"
[cmake] 
[cmake]   is not able to compile a simple test program.
[cmake] 
[cmake]   It fails with the following output:
[cmake] 
[cmake]     Change Dir: 'C:/Users/home/OneDrive/Documents/CODE STUFF/C++/Computer Vision/build/CMakeFiles/CMakeScratch/TryCompile-nm0tvn'
[cmake]     
[cmake]     Run Build Command(s): C:/msys64/mingw64/bin/ninja.exe -v cmTC_a2552
[cmake]     [1/2] C:\PROGRA~2\MICROS~3\2022\BUILDT~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x86\cl.exe  /nologo   /DWIN32 /D_WINDOWS  /Ob0 /Od /RTC1 -MDd -Zi /showIncludes /FoCMakeFiles\cmTC_a2552.dir\testCCompiler.c.obj /FdCMakeFiles\cmTC_a2552.dir\ /FS -c "C:\Users\home\OneDrive\Documents\CODE STUFF\C++\Computer Vision\build\CMakeFiles\CMakeScratch\TryCompile-nm0tvn\testCCompiler.c"
[cmake]     [2/2] C:\WINDOWS\system32\cmd.exe /C "cd . && "C:\Users\home\OneDrive\Documents\CODE STUFF\cmake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_a2552.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\PROGRA~2\MICROS~3\2022\BUILDT~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x86\link.exe /nologo CMakeFiles\cmTC_a2552.dir\testCCompiler.c.obj  /out:cmTC_a2552.exe /implib:cmTC_a2552.lib /pdb:cmTC_a2552.pdb /version:0.0 /machine:X86  /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 ."
[cmake]     FAILED: cmTC_a2552.exe 
[cmake]     C:\WINDOWS\system32\cmd.exe /C "cd . && "C:\Users\home\OneDrive\Documents\CODE STUFF\cmake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_a2552.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\PROGRA~2\MICROS~3\2022\BUILDT~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x86\link.exe /nologo CMakeFiles\cmTC_a2552.dir\testCCompiler.c.obj  /out:cmTC_a2552.exe /implib:cmTC_a2552.lib /pdb:cmTC_a2552.pdb /version:0.0 /machine:X86  /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 ."
[cmake]     RC Pass 1: command "rc /fo CMakeFiles\cmTC_a2552.dir/manifest.res CMakeFiles\cmTC_a2552.dir/manifest.rc" failed (exit code 0) with the following output:
[cmake]     no such file or directory
[cmake]     ninja: build stopped: subcommand failed.
[cmake]     
[cmake]     
[cmake] 
[cmake]   
[cmake] 
[cmake]   CMake will not be able to correctly generate this project.
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:2 (project)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: "C:\Users\home\OneDrive\Documents\CODE STUFF\cmake\bin\cmake.exe" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE "-SC:/Users/home/OneDrive/Documents/CODE STUFF/C++/Computer Vision" "-Bc:/Users/home/OneDrive/Documents/CODE STUFF/C++/Computer Vision/build" -G Ninja exited with code: 1
[visual-studio] Parse '\' failed

Turns out I was using a GCC compiler with a MSVC library of OpenCV, so I decided to switch the kit to MSCV. Now CMAKE can't compile with MSVC.

I have no idea how to solve this.

0

There are 0 best solutions below