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

Failed to generate projects for older Visual Studio #1352

Closed
enpinion opened this issue Jul 4, 2020 · 7 comments
Closed

Failed to generate projects for older Visual Studio #1352

enpinion opened this issue Jul 4, 2020 · 7 comments
Labels
bug a bug in the product Feature: configure regression used to work and no longer does. Regressions are typically high priority
Milestone

Comments

@enpinion
Copy link

enpinion commented Jul 4, 2020

Brief Issue Summary

Generating for older Visual Studio like 2010 causes an error.

Expected:

Generate projects for older Visual Studio. (VisualStudio.10.0 -amd64)

Apparent Behavior:

  1. Configure CMake projects for previous Visual Studio versions (e.g. VisualStudio.10.0 - amd64)
  2. Error

CMake Tools Log

<!-- Paste the log contents HERE -->
[main] Configuring folder: cmakesanity
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.exe" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=MinSizeRel -Hs:/__SANDBOX__/cmakesanity -Bs:/__SANDBOX__/cmakesanity/build -G "Visual Studio 10 2010" -T host=x64 -A x64
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Error at CMakeLists.txt:3 (project):
[cmake]   Generator
[cmake] 
[cmake]     Visual Studio 10 2010
[cmake] 
[cmake]   given toolset specification
[cmake] 
[cmake]     host=x64
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "S:/__SANDBOX__/cmakesanity/build/CMakeFiles/CMakeOutput.log".
[cmake]   that contains invalid field 'host=x64'.
[cmake] 
[cmake] 

Developer Tools Log

<!-- Paste the log contents HERE -->

Platform and Versions

  • Operating System: Windows 10 1909 AMD64
  • CMake Version: 3.17.3
  • VSCode Version: 1.46.1
  • CMake Tools Extension Version: 1.41
  • Compiler/Toolchain: MSVC 16.00.40219.01/Visual Studio 2010 10.0.40219.1 SP1

Other Notes/Information

For older Visual Studio, either should generate without -T host=x64 or use -G "Visual Studio 10 2010 Win64" for older CMake versions <=3.12.4
and CMAKE_GENERATOR_TOOLSET only supports VS2013 or later.
https://cmake.org/cmake/help/git-stage/variable/CMAKE_GENERATOR_TOOLSET.html#variable:CMAKE_GENERATOR_TOOLSET
https://cmake.org/cmake/help/v3.12/generator/Visual%20Studio%2010%202010.html
https://cmake.org/cmake/help/v3.13/generator/Visual%20Studio%2010%202010.html

@bobbrow bobbrow added bug a bug in the product Feature: configure labels Jul 6, 2020
@bobbrow bobbrow added this to the On Deck milestone Jul 6, 2020
@bobbrow bobbrow added the regression used to work and no longer does. Regressions are typically high priority label Jul 6, 2020
@andreeis
Copy link
Contributor

Fixed with #1481

@magicdmer
Copy link

I meet the same question with new CMake tool

VSCode output

 CMake Error at CMakeLists.txt:2 (project):Generator

  Visual Studio 10 2010

given toolset specification

  host=x86

that contains invalid field 'host=x86'.CMake (project)

Platform and Versions

  • Operating System: Windows 7 sp1
  • CMake Version: 3.19.0
  • VSCode Version: 1.54.1
  • CMake Tools Extension Version: 1.6.0
  • Compiler/Toolchain: VisualStudio.10.0 - x86

@andreeis
Copy link
Contributor

@magicdmer, thank you for letting us know that you still see this symptom. We are ready to reactivate this report and investigate it again, but before let's make sure. Here are a few cleanup steps that you can do before verifying again:

  • rescan your kits with the command "CMake: Scan for kits" in the palette. Check the content of cmake-tools-kits.json (you can open it with the command "CMake: Edit User-Local CMake Kits" in the palette) after the rescan: does your VisualStudio.10.0 kit still have a toolset keyword generated?
  • actually share for us the content of cmake-tools-kits.json (the VS 10.0 section is enough, not the more recent installations that are detected)
  • perform a clean configure with the command: "CMake: Delete cache and reconfigure". After doing this, does configuring still fail for you?

@magicdmer
Copy link

@andreeis I had already removed toolset from cmake-tools-kits.json and not generated again

@zadigus
Copy link

zadigus commented Jul 5, 2021

@andreeis I am experiencing the same issue with visual studio code 1.57.1 and the CMake Tools extension's version 1.7.3. I see your fix in the release notes. Therefore there is certainly something I am doing wrong. Here's my cmake-tools-kits.json:

[
  {
    "name": "GCC 9.2.0",
    "compilers": {
      "C": "C:\\MinGW\\bin\\gcc.exe",
      "CXX": "C:\\MinGW\\bin\\g++.exe"
    },
    "preferredGenerator": {
      "name": "MinGW Makefiles"
    },
    "environmentVariables": {
      "CMT_MINGW_PATH": "C:\\MinGW\\bin"
    }
  },
  {
    "name": "GCC 9.2.0 mingw32",
    "compilers": {
      "C": "C:\\MinGW\\bin\\mingw32-gcc.exe",
      "CXX": "C:\\MinGW\\bin\\mingw32-g++.exe"
    },
    "preferredGenerator": {
      "name": "MinGW Makefiles"
    },
    "environmentVariables": {
      "CMT_MINGW_PATH": "C:\\MinGW\\bin"
    }
  },
  {
    "name": "GCC for mingw32 9.2.0",
    "compilers": {
      "C": "C:\\MinGW\\bin\\mingw32-gcc.exe",
      "CXX": "C:\\MinGW\\bin\\mingw32-g++.exe"
    },
    "preferredGenerator": {
      "name": "MinGW Makefiles"
    },
    "environmentVariables": {
      "CMT_MINGW_PATH": "C:\\MinGW\\bin"
    }
  },
  {
    "name": "Visual Studio Professional 2019 Release - amd64",
    "visualStudio": "33a40df0",
    "visualStudioArchitecture": "x64",
    "preferredGenerator": {
      "name": "Visual Studio 16 2019",
      "platform": "x64",
      "toolset": "host=x64"
    }
  },
  {
    "name": "Visual Studio Professional 2019 Release - amd64_x86",
    "visualStudio": "33a40df0",
    "visualStudioArchitecture": "x64",
    "preferredGenerator": {
      "name": "Visual Studio 16 2019",
      "platform": "win32",
      "toolset": "host=x64"
    }
  },
  {
    "name": "Visual Studio Professional 2019 Release - x86",
    "visualStudio": "33a40df0",
    "visualStudioArchitecture": "x86",
    "preferredGenerator": {
      "name": "Visual Studio 16 2019",
      "platform": "win32",
      "toolset": "host=x86"
    }
  },
  {
    "name": "Visual Studio Professional 2019 Release - x86_amd64",
    "visualStudio": "33a40df0",
    "visualStudioArchitecture": "x86",
    "preferredGenerator": {
      "name": "Visual Studio 16 2019",
      "platform": "x64",
      "toolset": "host=x86"
    }
  },
  {
    "name": "VisualStudio.10.0 - amd64",
    "visualStudio": "VisualStudio.10.0",
    "visualStudioArchitecture": "x64",
    "preferredGenerator": {
      "name": "Visual Studio 10 2010",
      "platform": "x64"
    }
  },
  {
    "name": "VisualStudio.10.0 - x86",
    "visualStudio": "VisualStudio.10.0",
    "visualStudioArchitecture": "x86",
    "preferredGenerator": {
      "name": "Visual Studio 10 2010",
      "platform": "win32"
    }
  },
  {
    "name": "VisualStudio.10.0 - x86_amd64",
    "visualStudio": "VisualStudio.10.0",
    "visualStudioArchitecture": "x86",
    "preferredGenerator": {
      "name": "Visual Studio 10 2010",
      "platform": "x64"
    }
  }
]

That is what I get after a CMake: Scan for kits. How do make the toolset appear for my visual studio 2010 kits or how do I prevent visual studio code from adding the options -T host=x64 -A x64 to the cmake command?

@andreeis
Copy link
Contributor

andreeis commented Jul 7, 2021

@zadigus, it is possible that we were off by 1 in a VS version check. This is a different problem than the original entry in this GitHub issue so I am opening a new report for your case. We don't have time to address this immediately but we are welcoming PRs from the community. The fix would be super easy if anyone has time to properly test it with more VS installations, especially including older ones.

@mtajic
Copy link

mtajic commented Jul 16, 2021

I have the same issue with Visual Studio 2017, VS Code 1.58.1, and Cmake Tools v1.7.3

[cmake] Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19042.
[cmake] CMake Error at CMakeLists.txt:3 (project):
[cmake]   Generator
[cmake] 
[cmake]     Visual Studio 15 2017
[cmake] 
[cmake]   given toolset specification
[cmake] 
[cmake]     host=x86
[cmake] 
[cmake]   that contains invalid field 'host=x86'.
[cmake] 
[cmake] 
[cmake] Configuring incomplete, errors occurred!

@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 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: configure regression used to work and no longer does. Regressions are typically high priority
Projects
None yet
Development

No branches or pull requests

7 participants