-
Notifications
You must be signed in to change notification settings - Fork 991
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
Feature/msvc #8201
Feature/msvc #8201
Changes from 25 commits
0a6f828
27c6fc4
72f6bee
369143b
fb110ba
ee99a73
cfc28fe
c55072f
b245c43
c363312
fb6b57b
e98d911
ae91af5
3c3a7b3
3bb3e4d
ef36fd2
2000c85
640b134
fca3c79
1110c80
e9df343
c78bad2
59c2ab2
0766d14
40fb8f0
315de05
0c7935f
9bdeca1
72adaf3
8cce2e1
b252e83
637a9e7
3983c43
2738424
47c339b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,15 @@ def get_generator(conanfile): | |
|
||
compiler = conanfile.settings.get_safe("compiler") | ||
compiler_version = conanfile.settings.get_safe("compiler.version") | ||
|
||
if compiler == "msvc": | ||
version = compiler_version[:4] # Remove the latest version number 19.1X if existing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line (and the line below) may raise, need sanity checks (and maybe tests) |
||
_visuals = {'19.0': '14 2015', | ||
'19.1': '15 2017', | ||
'19.2': '16 2019'}[version] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it is where we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, probably we need not only vswhere, but also some easy way to configure it, because if vswhere finds VS2017 and VS2019, and both have the v140 toolset for older versions, which one will it pick? Seems a task for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make any difference? The tools (compiler, linker,...) will be exactly the same, won't they? Can you have more than one instance of the same MSVC installed and detected by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that might be different instances of compilers for VS2019 and VS2017 with the same toolset. they probably might have the same version, but I think they installed and updated intependently. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the approach of choosing one at random is a good one. Besides, asking information about the installed toolsets is not possible in vswhere: microsoft/vswhere#151 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what vswhere does (from that same link): "[vswhere] finds the installation path (and other basic information) of a version of Visual Studio that meets basic requirements" (#3573 (comment)):
The toolset is a requirement, vswhere returns the VS version that satisfies that requirement (VS 2017, VS 2019,...) which is the input we need for the CMake generator. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I have tried that. The toolset component name that you pass to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Each toolset has a different component name (#3573 (comment)):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have tried them too, but don't seem to work as expected, or at least they are trickier than they look. I didn't succeed in identifying the toolsets I have installed in my different VS versions. I will try again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Results differ from documented (or at least documentation is not very clear).
|
||
base = "Visual Studio %s" % _visuals | ||
return base | ||
|
||
compiler_base = conanfile.settings.get_safe("compiler.base") | ||
arch = conanfile.settings.get_safe("arch") | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,3 +2,17 @@ | |||||
from .toolchain import MSBuildToolchain | ||||||
from .msbuild import MSBuild | ||||||
from .msbuilddeps import MSBuildDeps | ||||||
|
||||||
|
||||||
def msvc_runtime_flag(conanfile): | ||||||
settings = conanfile.settings | ||||||
compiler = settings.get_safe("compiler") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer to condition it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. up to you :) |
||||||
runtime = settings.get_safe("compiler.runtime") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is for the intel compiler, I prefer to wait until the next iteration. For a start, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, that might not be not just Intel compiler, but any custom compiler with custom settings using |
||||||
if compiler == "Visual Studio": | ||||||
return runtime | ||||||
if compiler == "msvc": | ||||||
runtime_type = settings.get_safe("compiler.runtime_type") | ||||||
if runtime == "static": | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a better implementation (from below):
also, why not reuse? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed. Premature reuse is like premature optimization. It leads to wrong and obscure abstractions. I prefer stronger encapsulation, and knowing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code was from |
||||||
return "MTd" if runtime_type == "Debug" else "MT" | ||||||
else: | ||||||
return "MDd" if runtime_type == "Debug" else "MD" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,13 @@ | |
threads: [None, posix, win32] # Windows MinGW | ||
exception: [None, dwarf2, sjlj, seh] # Windows MinGW | ||
cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20] | ||
msvc: | ||
version: ["19.0", | ||
memsharded marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"19.1", "19.10", "19.11", "19.12", "19.13", "19.14", "19.15", "19.16", | ||
"19.2", "19.20", "19.21", "19.22", "19.23", "19.24", "19.25", "19.26", "19.27", "19.28"] | ||
runtime: [static, dynamic] | ||
runtime_type: [Debug, Release] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this requires a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was automated. If |
||
cppstd: [None, 14, 17, 20] | ||
Visual Studio: &visual_studio | ||
runtime: [MD, MT, MTd, MDd] | ||
version: ["8", "9", "10", "11", "12", "14", "15", "16"] | ||
|
@@ -485,6 +492,14 @@ def full_transitive_package_id(self): | |
except ConanException: | ||
return None | ||
|
||
@property | ||
def msvc_visual_incompatible(self): | ||
try: | ||
visual_comp = self.get_item("general.msvc_visual_incompatible") | ||
return visual_comp.lower() in ("1", "true") | ||
except ConanException: | ||
return None | ||
memsharded marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@property | ||
def short_paths_home(self): | ||
short_paths_home = get_env("CONAN_USER_HOME_SHORT") | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -575,6 +575,27 @@ def header_only(self): | |||||
self.options.clear() | ||||||
self.requires.clear() | ||||||
|
||||||
def msvc_compatible(self): | ||||||
if self.settings.compiler != "msvc": | ||||||
return | ||||||
|
||||||
compatible = self.clone() | ||||||
version = compatible.settings.compiler.version | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
runtime = compatible.settings.compiler.runtime | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nop, at this point, using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's very possible There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So far this would be an unsupported case, the |
||||||
runtime_type = compatible.settings.compiler.runtime_type | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
compatible.settings.compiler = "Visual Studio" | ||||||
version = str(version)[:4] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may raise, need a sanity check (maybe deserves a test) |
||||||
_visuals = {'19.0': '14', | ||||||
'19.1': '15', | ||||||
'19.2': '16'} | ||||||
compatible.settings.compiler.version = _visuals[version] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may raise, need a sanity check (maybe deserves a test) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, this is a preliminary implementation, this needs to be improved. |
||||||
runtime = "MT" if runtime == "static" else "MD" | ||||||
if runtime_type == "Debug": | ||||||
runtime = "{}d".format(runtime) | ||||||
compatible.settings.compiler.runtime = runtime | ||||||
return compatible | ||||||
|
||||||
def vs_toolset_compatible(self): | ||||||
"""Default behaviour, same package for toolset v140 with compiler=Visual Studio 15 than | ||||||
using Visual Studio 14""" | ||||||
|
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.