Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not finding the Visual C++ 2015 compiler from CMakePresets.json #2516

Closed
bradenmcd opened this issue Apr 21, 2022 · 7 comments · Fixed by #2524
Closed

Not finding the Visual C++ 2015 compiler from CMakePresets.json #2516

bradenmcd opened this issue Apr 21, 2022 · 7 comments · Fixed by #2524
Labels
bug a bug in the product Feature: presets help wanted we currently are not planning work on this and would like help from the open source community
Milestone

Comments

@bradenmcd
Copy link

Brief Issue Summary

My configurePreset includes:

"architecture": {
  "value": "x64",
  "strategy": "external"
},
"toolset": {
  "value": "v140",
  "strategy": "external"
}

...and I have Visual Studio 2015 installed. But when I try to build using this configuration, CMake configure fails to find the C++ compiler.

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.66.2",
  "cmtVersion": "1.10.5",
  "configurations": [
    {
      "folder": "c:\\SRCDIR",
      "cmakeVersion": "3.21.4",
      "configured": true,
      "generator": "",
      "usesPresets": true,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

[main] Building folder: BUILDDIR 
[main] Saving open files before configure/build
[main] Configuring folder: BUILDDIR 
[main] Saving open files before configure/build
[driver] Start configure 
[driver] Running pre-configure checks and steps
[cmakefileapi-driver] Configuring using preset
[cmakefileapi-driver] Invoking CMake C:\Program Files\CMake\bin\cmake.EXE with arguments ["-DCMAKE_BUILD_TYPE=RelWithDebInfo","-DCMAKE_TOOLCHAIN_FILE=c:/SRCDIR/Windows-toolchain.cmake","-DCMAKE_INSTALL_PREFIX=C:/BUILDDIR/v140-x64-RelWithDebInfo/install","-Sc:/SRCDIR","-BC:/BUILDDIR/v140-x64-RelWithDebInfo","-G","Ninja"]
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_BUILD_TYPE=RelWithDebInfo "-DCMAKE_TOOLCHAIN_FILE=c:/SRCDIR/Windows-toolchain.cmake" -DCMAKE_INSTALL_PREFIX=C:/BUILDDIR/v140-x64-RelWithDebInfo/install "-Sc:/SRCDIR" -BC:/BUILDDIR/v140-x64-RelWithDebInfo -G Ninja
[cmake] -- Found Git: C:/Apps/Git/cmd/git.exe (found version "2.35.2.windows.1") 
[cmake] -- The CXX compiler identification is unknown
[cmake] CMake Error at CMakeLists.txt:37 (project):
[cmake]   No CMAKE_CXX_COMPILER could be found.
[cmake] 
[cmake]   Tell CMake where to find the compiler by setting either the environment
[cmake]   variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
[cmake]   to the compiler, or to the compiler name if it is in the PATH.
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "C:/BUILDDIR/v140-x64-RelWithDebInfo/CMakeFiles/CMakeOutput.log".
[cmake] See also "C:/BUILDDIR/v140-x64-RelWithDebInfo/CMakeFiles/CMakeError.log".
[extension] [3967] cmake.build finished (returned 1)

Additional Information

I've used BUILDDIR and SRCDIR above to redact potentially sensitive information.

@bobbrow
Copy link
Member

bobbrow commented Apr 22, 2022

Thanks for reporting this. We haven't tested this codepath with VS 2015 and it sounds like there are some deficiencies. We'll need to install it and see what's going on.

We may not get to this immediately, so if you're blocked and have a chance to help us debug it, I would set a breakpoint here. This is where we attempt to locate the script that sets the MSVC environment variables.

for (const vs of vsInstalls) {

@bobbrow bobbrow added bug a bug in the product help wanted we currently are not planning work on this and would like help from the open source community Feature: presets labels Apr 22, 2022
@bobbrow
Copy link
Member

bobbrow commented Apr 22, 2022

I found that I have VS 2015 installed on my laptop, but as I started to look at this, I saw that a toolchain is being used in your configure command. Are you able to share the relevant portions of that and/or any cacheVariables in your preset (e.g. the value of CMAKE_[CXX|C]_COMPILER)?

@bradenmcd
Copy link
Author

I am; though I also tried removing the toolchain file reference altogether; and that didn't seem to have any effect on the outcome.

There's nothing sensitive in the toolchain file, though. Here are its contents:

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE x64)
set(CMAKE_CXX_FLAGS "/EHsc /Zc:strictStrings /WX /W3 /we4100 /w34127 /w34201 /w34244 /w34245 /w34265 /w34315 /w34458 /w34459 /w34701 /w34703 /wd4800"
    CACHE STRING "Flags used by the CXX compiler during all build types.")
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /Oi /Ot /DNDEBUG"
    CACHE STRING "Flags used by the CXX compiler during RELEASE builds.")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Zi /O2 /Ob2 /Oi /Ot /DNDEBUG"
    CACHE STRING "Flags used by the CXX compiler during RELWITHDEBINFO builds.")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /DYNAMICBASE:NO /OPT:REF"
    CACHE STRING "Flags used by the linker during RELEASE builds.")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/debug /MAP /INCREMENTAL:NO /DYNAMICBASE:NO /OPT:REF"
    CACHE STRING "Flags used by the linker during RELWITHDEBINFO builds.")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /DYNAMICBASE:NO /OPT:REF"
    CACHE STRING "Flags used by the linker during the creation of modules during RELEASE builds.")
set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "/debug /MAP /INCREMENTAL:NO /DYNAMICBASE:NO /OPT:REF"
    CACHE STRING "Flags used by the linker during the creation of modules during RELWITHDEBINFO builds.")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /DYNAMICBASE:NO /OPT:REF"
    CACHE STRING "Flags used by the linker during the creation of shared libraries during RELEASE builds.")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "/debug /MAP /INCREMENTAL:NO /DYNAMICBASE:NO /OPT:REF"
    CACHE STRING "Flags used by the linker during the creation of shared libraries during RELWITHDEBINFO builds.")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO ON)

There is just one cache variable set in the preset:

"cacheVariables": {
  "CMAKE_BUILD_TYPE": "RelWithDebInfo"
}

As far as debugging this myself, I'm happy to do so; but I've never written/debugged a VSCode extension before; so, I'll have to read up on how to do that.

@bobbrow
Copy link
Member

bobbrow commented Apr 22, 2022

Thanks for the extra info! I plan to take a look at this on Monday.

As far as debugging the extension goes, it's actually really easy. It's basically: install Nodejs, install yarnpkg, open the repo in VS Code and press F5.

Our guide with links to the tools mentioned is here: https://github.com/microsoft/vscode-cmake-tools/blob/main/CONTRIBUTING.md

@bradenmcd
Copy link
Author

Unfortunately, the machine where I've got all this set up is normally on a corporate VPN, which is apparently a scenario where corepack/yarn does not play nicely. Even temporarily shutting off my VPN didn't seem to get me anywhere.

@bobbrow
Copy link
Member

bobbrow commented Apr 25, 2022

Ok. I haven't tried using corepack. I just use npm install -g yarn to install it. We're using version 1 of yarn still.

In any case, I have a fix for this issue which is out for review now.

@bobbrow bobbrow modified the milestones: On Deck, 1.11.0 Apr 26, 2022
@bobbrow
Copy link
Member

bobbrow commented Apr 26, 2022

The fix for this will be available in tomorrow's pre-release version.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug a bug in the product Feature: presets help wanted we currently are not planning work on this and would like help from the open source community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants