microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.46k stars 446 forks source link

detecting vs2015 comes with vs2019 properly #1905

Open lygstate opened 3 years ago

lygstate commented 3 years ago

According to C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat We can specify options for vs2015 or vs 2017


:usage_error
echo [ERROR:%~nx0] Error in script usage. The correct usage is:
goto :usage

:usage
echo Syntax:
echo     %~nx0 [arch] [platform_type] [winsdk_version] [-vcvars_ver=vc_version] [-vcvars_spectre_libs=spectre_mode]
echo where :
echo     [arch]: x86 ^| amd64 ^| x86_amd64 ^| x86_arm ^| x86_arm64 ^| amd64_x86 ^| amd64_arm ^| amd64_arm64
echo     [platform_type]: {empty} ^| store ^| uwp
echo     [winsdk_version] : full Windows 10 SDK number (e.g. 10.0.10240.0) or "8.1" to use the Windows 8.1 SDK.
echo     [vc_version] : {none} for latest installed VC++ compiler toolset ^|
echo                    "14.0" for VC++ 2015 Compiler Toolset ^|
echo                    "14.xx" for the latest 14.xx.yyyyy toolset installed (e.g. "14.11") ^|
echo                    "14.xx.yyyyy" for a specific full version number (e.g. "14.11.25503")
echo     [spectre_mode] : {none} for libraries without spectre mitigations ^|
echo                      "spectre" for libraries with spectre mitigations
echo:
echo The store parameter sets environment variables to support Universal Windows Platform application
echo development and is an alias for 'uwp'.
echo:
echo For example:
echo     %~nx0 x86_amd64
echo     %~nx0 x86_amd64 10.0.10240.0
echo     %~nx0 x86_arm uwp 10.0.10240.0
echo     %~nx0 x86_arm onecore 10.0.10240.0 -vcvars_ver=14.0
echo     %~nx0 x64 8.1
echo     %~nx0 x64 store 8.1
echo:
echo Please make sure either Visual Studio or C++ Build SKU is installed.
goto :end

:missing
echo The specified configuration type is missing.  The tools for the
echo configuration might not be installed.
goto :end

:end
set __VCVARSALL_TARGET_ARCH=
set __VCVARSALL_HOST_ARCH=
set __VCVARSALL_STORE=
set __VCVARSALL_WINSDK=
set __VCVARSALL_PARSE_ERROR=
set __VCVARSALL_CLEAN_ENV=
set VSCMD_VCVARSALL_INIT=
set __VCVARSALL_VSDEVCMD_ARGS=
set __VCVARSALL_HELP=
set __VCVARSALL_VER=
set __VCVARSALL_SPECTRE=

So we can detecting vs2015 proplery

andreeis commented 3 years ago

Thank you for the idea, I was not aware of this user scenario for the vcvars script. We may not be able to implement this immediately but we will monitor the community reactions (please give a thumbs up on the first entry of this GitHub issue) to find how this best fits in our backlog.

andreeis commented 3 years ago

@lygstate, I just tried -vcvars_ver=14.0 for a VS 2019 vcvarsall.bat and it points to a VS 14.0 installation (as opposed to some different toolset with the same version but placed within the VS 2019 location). And that VS 14.0 is detected already as a kit by this extension. Please give us a few more details about what is not working now, how do you run vcvars, what toolset is using and from where, is it not present in cmake-tools-kits.json already?

lygstate commented 3 years ago

@lygstate, I just tried -vcvars_ver=14.0 for a VS 2019 vcvarsall.bat and it points to a VS 14.0 installation (as opposed to some different toolset with the same version but placed within the VS 2019 location). And that VS 14.0 is detected already as a kit by this extension. Please give us a few more details about what is not working now, how do you run vcvars, what toolset is using and from where, is it not present in cmake-tools-kits.json already?

Yeap, that's what I want, currently the vscode cmake tools didn't detect vs2015 by using -vcvars_ver=14.0 when vs 2019 installed. And detecting directly with "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" will fail building when the newest windows sdk are installed(The rc.exe can not found).

andreeis commented 3 years ago

Just to confirm, you are opening VSCode from a terminal where you didn't run vcvars yourself, right? You know that the extension does this when needed: run the appropriate vcvars script, from the correct location, with the correct arguments.... well ideally, there can always be bugs about that.

So you have both VS 2019 and VS 2015 installed and you don't see any VS 2015 kits detected when scanning for kits? And before (before installing latest sdk if I understand correctly) VS 2015 was found by the kits scan? I haven't seen this, VS 2015 is properly detected where I tried this. I'll brainstorm more about why this can happen and I'll see what else I can try to reproduce this.

What's a "cmake.loggingLevel": "Debug" logging in the "CMake/Build" output channel after scanning for kits?

lygstate commented 3 years ago

This is used to resolve the following issue: The vs2015 installed with vs2019 can not be used, because using newest SDK along with vs vs2019

[main] Configuring folder: acrop-cat1-device 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_GENERATOR:STRING=Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -He:/CI-Cor/acrop/acrop-cat1-device -Be:/CI-Cor/acrop/acrop-cat1-device/build/ninja-x64-pc-windows-msvc-14-debug
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is MSVC 19.0.24245.0
[cmake] -- The CXX compiler identification is MSVC 19.0.24245.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 14.0/VC/bin/amd64/cl.exe
[cmake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe - broken
[cmake] CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
[cmake]   The C compiler
[cmake] 
[cmake]     "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/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: E:/CI-Cor/acrop/acrop-cat1-device/build/ninja-x64-pc-windows-msvc-14-debug/CMakeFiles/CMakeTmp
[cmake]     
[cmake]     Run Build Command(s):C:/PROGRA~1/CMake/bin/ninja.exe cmTC_e4435 && [1/2] Building C object CMakeFiles\cmTC_e4435.dir\testCCompiler.c.obj
[cmake]     [2/2] Linking C executable cmTC_e4435.exe
[cmake]     FAILED: cmTC_e4435.exe 
[cmake]     cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_e4435.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\PROGRA~2\MICROS~3.0\VC\bin\amd64\link.exe /nologo CMakeFiles\cmTC_e4435.dir\testCCompiler.c.obj  /out:cmTC_e4435.exe /implib:cmTC_e4435.lib /pdb:cmTC_e4435.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 ."
[cmake]     RC Pass 1: command "rc /fo CMakeFiles\cmTC_e4435.dir/manifest.res CMakeFiles\cmTC_e4435.dir/manifest.rc" failed (exit code 0) with the following output:
[cmake]     系统找不到指定的文件。
[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:3 (project)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "E:/CI-Cor/acrop/acrop-cat1-device/build/ninja-x64-pc-windows-msvc-14-debug/CMakeFiles/CMakeOutput.log".
[cmake] See also "E:/CI-Cor/acrop/acrop-cat1-device/build/ninja-x64-pc-windows-msvc-14-debug/CMakeFiles/CMakeError.log".
lygstate commented 3 years ago
[main] Configuring folder: win-polyfill 
[driver] Removing e:/CI-Cor-Ready/15/im/win-polyfill/build/i686-pc-windows-msvc-14-debug/CMakeCache.txt
[driver] Removing e:\CI-Cor-Ready\15\im\win-polyfill\build\i686-pc-windows-msvc-14-debug\CMakeFiles
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli "-DCMAKE_PREFIX_PATH=C:/Qt/Qt5.9.9/5.9.9/msvc2015_64;D:/Qt/Qt5.9.9/5.9.9/msvc2015_64" -DBUILD_TESTING:BOOL=TRUE -DCMAKE_EXE_LINKER_FLAGS_INIT=/SUBSYSTEM:CONSOLE,5.01 -DCMAKE_C_STANDARD_LIBRARIES= -DCMAKE_CXX_STANDARD_LIBRARIES= -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -He:/CI-Cor-Ready/15/im/win-polyfill -Be:/CI-Cor-Ready/15/im/win-polyfill/build/i686-pc-windows-msvc-14-debug -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is MSVC 19.0.24245.0
[cmake] -- The CXX compiler identification is MSVC 19.0.24245.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 14.0/VC/bin/amd64_x86/cl.exe
[cmake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64_x86/cl.exe - broken
[cmake] CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
[cmake]   The C compiler
[cmake] 
[cmake]     "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64_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: E:/CI-Cor-Ready/15/im/win-polyfill/build/i686-pc-windows-msvc-14-debug/CMakeFiles/CMakeTmp
[cmake]     
[cmake]     Run Build Command(s):C:/PROGRA~1/CMake/bin/ninja.exe cmTC_b7466 && [1/2] Building C object CMakeFiles\cmTC_b7466.dir\testCCompiler.c.obj
[cmake]     [2/2] Linking C executable cmTC_b7466.exe
[cmake]     FAILED: cmTC_b7466.exe 
[cmake]     cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_b7466.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\PROGRA~2\MICROS~3.0\VC\bin\AMD64_~2\link.exe /nologo CMakeFiles\cmTC_b7466.dir\testCCompiler.c.obj  /out:cmTC_b7466.exe /implib:cmTC_b7466.lib /pdb:cmTC_b7466.pdb /version:0.0 /SUBSYSTEM:CONSOLE,5.01 /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_b7466.dir/manifest.res CMakeFiles\cmTC_b7466.dir/manifest.rc" failed (exit code 0) with the following output:
[cmake]     系统找不到指定的文件。
[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:5 (project)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "E:/CI-Cor-Ready/15/im/win-polyfill/build/i686-pc-windows-msvc-14-debug/CMakeFiles/CMakeOutput.log".
[cmake] See also "E:/CI-Cor-Ready/15/im/win-polyfill/build/i686-pc-windows-msvc-14-debug/CMakeFiles/CMakeError.log".

May patch didn't fixed this issue, I need submit a fix

github-actions[bot] commented 10 months ago

This issue is now marked as 'stale-old' due to there being no activity on it for the past 720 days. Unless the 'stale-old' label is removed or the issue is commented on, this will be remain open for at least 14 days and then it may be closed. If you would like to make this issue exempt from getting stale, please add the 'stale-exempt' label.