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

detect msvc and version when CC/CXX point to cl.exe #14364

Merged

Conversation

jcar87
Copy link
Contributor

@jcar87 jcar87 commented Jul 25, 2023

Changelog: Feature: conan profile detect can now detect the version of msvc when invoked within a Visual Studio prompt where CC or CXX are defined and pointing to the cl compiler executable
Docs: Omit

This PR fixes issue where conan profile detect is invoked from an active Visual Studio prompt that also happens to have CC or CXX 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 if conan profile detect needs to run when using cmake-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 contains Microsoft and that the version contains 3 or more components. We also avoid running this logic if clang 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 and cl.exe (falls back to finding it in PATH), or the full path to cl.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.

conans/client/conf/detect.py Outdated Show resolved Hide resolved
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good

conans/client/conf/detect.py Show resolved Hide resolved
conans/test/functional/command/profile_test.py Outdated Show resolved Hide resolved
@memsharded memsharded added this to the 2.0.10 milestone Aug 1, 2023
Copy link
Member

@memsharded memsharded left a 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?

@jcar87 jcar87 marked this pull request as ready for review August 2, 2023 11:12
@jcar87
Copy link
Contributor Author

jcar87 commented Aug 2, 2023

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).

@jcar87 jcar87 merged commit 05947c5 into conan-io:release/2.0 Aug 2, 2023
@jcar87 jcar87 deleted the lcc/feature/profile-detect-cc-cl branch August 2, 2023 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants