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

MSVC_VERSION is incorrect when cmake configure project with tool kit clang-cl #1053

Closed
L-Sun opened this issue Feb 8, 2020 · 3 comments
Closed
Labels
bug a bug in the product
Milestone

Comments

@L-Sun
Copy link

L-Sun commented Feb 8, 2020

Brief Issue Summary

When I configure my project, the cmake variable ${MSVC_VERSION} output incorrectly.
Here is my CMakeLists.txt

cmake_minimum_required(VERSION 3.15)

project(MyProject)

add_executable(main main.cpp)
if(MSVC)
    message("MSVC_VERSION: ${MSVC_VERSION}")
endif(MSVC)

Expected:

  1. run command CMake: Delete Cache and Reconfigure
  2. and Output panel will show:
...
[cmake] MSVC_VERSION: 1924
[cmake]  
[cmake] -- Configuring done
[cmake] -- Generating done

Apparent Behavior:

  1. run command CMake: Delete Cache and Reconfigure
  2. and Output panel show the following message
...
[cmake] MSVC_VERSION: 1911
[cmake]  
[cmake] -- Configuring done
[cmake] -- Generating done

Other Notes/Information

When I add 'VCToolsInstallDir' to MSVC_ENVIRONMENT_VARIABLES array in \.vscode\extensions\ms-vscode.cmake-tools-1.3.0\dist\main.js(or src/kit.ts) of extension.
and reconfigure my project. It works as expected. The cmake variable ${MSVC_VERSION} is correct.

Platform and Versions

  • Operating System: Windows
  • CMake Version: 3.16.4
  • VSCode Version: 1.42.0
  • CMake Tools Extension Version: 1.3.0
  • Compiler/Toolchain: clang-cl (11.0.0) + VS2019 (v16.4.4)
  • visualStudioArchitecture: amd64
@andreeis andreeis added this to the 1.4.0 milestone Feb 10, 2020
@andreeis andreeis added the bug a bug in the product label Feb 10, 2020
@bobbrow bobbrow modified the milestones: 1.4.0, On Deck Apr 7, 2020
@tklajnscek
Copy link
Contributor

+1
Just hit the same issue where Clang can't find the MSVC toolkit correctly.
Traced it down to this after many hours.

Is there any specific reason the VCToolsInstallDir is omitted from MSVC_ENVIRONMENT_VARIABLES ? Seems like someone generated this a while ago and it never got updated.

Clang uses VCToolsInstallDir to find the location of the toolkit.

See https://clang.llvm.org/doxygen/MSVC_8cpp_source.html -> findVCToolChainViaEnvironment()

@tklajnscek
Copy link
Contributor

Oh, just to be clear - in my case this doesn't simply mess up the MSVC_VERSION.
It completely fails to compile anything because the include/lib paths are set to non-existing locations.

tklajnscek added a commit to tklajnscek/vscode-cmake-tools that referenced this issue Aug 30, 2021
…ABLES so they get forwarded correctly. Fixes CMake and Clang detecting wrong MSVC toolkit version, paths etc. Fixes microsoft#1053
@bobbrow bobbrow modified the milestones: On Deck, 1.9.0 Sep 3, 2021
@andreeis
Copy link
Contributor

This fix is included in the 1.9.0 CMake Tools release. Please upgrade your extension in VSCode and let us know if you encounter any other issues.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 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
Projects
None yet
Development

No branches or pull requests

4 participants