-
Notifications
You must be signed in to change notification settings - Fork 989
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
detect msvc and version when CC/CXX point to cl.exe #14364
detect msvc and version when CC/CXX point to cl.exe #14364
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!
Can we then move out of draft and merge it? Anything missing?
Oops, should have taken it out of draft already :D will merge once CI reports a pass (I think changing it to not-a-draft restarted a build). |
Changelog: Feature:
conan profile detect
can now detect the version of msvc when invoked within a Visual Studio prompt whereCC
orCXX
are defined and pointing to thecl
compiler executableDocs: Omit
This PR fixes issue where
conan profile detect
is invoked from an active Visual Studio prompt that also happens to haveCC
orCXX
defined. This may be unusual for a developer to actively configure a prompt like this, but Visual Studio invoke may invoke CMake in such an environment, and this may cause issues ifconan profile detect
needs to run when usingcmake-conan
.This assumes that
cl.exe /?
always prints the copyright and the version in the first line. It doesn't assume a specific text since it can be localized to different languages, but it does assume that the string containsMicrosoft
and that the version contains 3 or more components. We also avoid running this logic ifclang
is part of the string - e.g.clang-cl
would not be handled and would fall back to the current behaviour.Tests cover defining
CC
in multiple ways, e.g.cl
andcl.exe
(falls back to finding it in PATH), or the full path tocl.exe
, which may be surrounded in double quotes as the path is very likely to contain spaces if it's installed in the default location.