From 3ac8445c0bc5ae2511aaa72f1c95335a0d443590 Mon Sep 17 00:00:00 2001 From: "Kevin A. Mitchell" Date: Thu, 1 Apr 2021 17:43:52 -0500 Subject: [PATCH 1/4] boost: Support settings.compiler.toolset for MSVC Translates settings.compiler.toolset settings in the form vNNN to a toolset version, overriding the use of the settings.compiler.version. This allows building with Visual Studio 2019 while using older toolsets. --- recipes/boost/all/conanfile.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/recipes/boost/all/conanfile.py b/recipes/boost/all/conanfile.py index d152d4e0f7e9d..47617030a79fb 100644 --- a/recipes/boost/all/conanfile.py +++ b/recipes/boost/all/conanfile.py @@ -6,6 +6,7 @@ from conans.errors import ConanInvalidConfiguration import glob import os +import re import sys import shlex import shutil @@ -1221,9 +1222,20 @@ def create_library_config(deps_name, name): filename = "%s/user-config.jam" % folder tools.save(filename, contents) + @property + def _msvc_toolset(self): + if self._is_msvc: + toolset = self.settings.compiler.get_safe("toolset", default="") + match = re.match(r'v(\d+)(\d)$', toolset) + if match: + return "%s.%s" % (match.group(1), match.group(2)) + @property def _toolset_version(self): if self._is_msvc: + toolset_from_setting = self._msvc_toolset + if toolset_from_setting: + return toolset_from_setting compiler_version = str(self.settings.compiler.version) if Version(compiler_version) >= "16": return "14.2" From da8ebc57d647d9f0b8525c158dfd6db5efdddf1b Mon Sep 17 00:00:00 2001 From: "Kevin A. Mitchell" Date: Thu, 1 Apr 2021 17:45:41 -0500 Subject: [PATCH 2/4] boost: Don't use tools.vcvars() if a toolset is specified It appears that if the environment variables are set, B2 will use the compiler set by tools.vcvars() despite the toolset setting. Even without tools.vcvars(), B2 seems to find the compiler and other tools. --- recipes/boost/all/conanfile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/recipes/boost/all/conanfile.py b/recipes/boost/all/conanfile.py index 47617030a79fb..8885572791f30 100644 --- a/recipes/boost/all/conanfile.py +++ b/recipes/boost/all/conanfile.py @@ -815,7 +815,10 @@ def build(self): full_command += ' --debug-configuration --build-dir="%s"' % self.build_folder self.output.warn(full_command) - with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): + # If sending a toolset to B2, setting the vcvars interferes with the compiler + # selection. + use_vcvars = self._is_msvc and not self._msvc_toolset + with tools.vcvars(self.settings) if use_vcvars else tools.no_op(): with tools.chdir(sources): # To show the libraries *1 # self.run("%s --show-libraries" % b2_exe) From 7a0732107b18cd1c6dcffa078e3e21b7a0b4f610 Mon Sep 17 00:00:00 2001 From: "Kevin A. Mitchell" Date: Mon, 23 Aug 2021 22:28:43 -0500 Subject: [PATCH 3/4] boost: Make _toolset_version use msvs_toolset() Eliminate all the guessing of version numbers and use the calculations and defaults in tools.msvs_toolset() Retain the conversion of the version number to what B2 wants: v141 -> 14.1 for instance. --- recipes/boost/all/conanfile.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/recipes/boost/all/conanfile.py b/recipes/boost/all/conanfile.py index 8885572791f30..9d6e73f93cff6 100644 --- a/recipes/boost/all/conanfile.py +++ b/recipes/boost/all/conanfile.py @@ -1226,26 +1226,12 @@ def create_library_config(deps_name, name): tools.save(filename, contents) @property - def _msvc_toolset(self): + def _toolset_version(self): if self._is_msvc: - toolset = self.settings.compiler.get_safe("toolset", default="") + toolset = tools.msvs_toolset(self) match = re.match(r'v(\d+)(\d)$', toolset) if match: return "%s.%s" % (match.group(1), match.group(2)) - - @property - def _toolset_version(self): - if self._is_msvc: - toolset_from_setting = self._msvc_toolset - if toolset_from_setting: - return toolset_from_setting - compiler_version = str(self.settings.compiler.version) - if Version(compiler_version) >= "16": - return "14.2" - elif Version(compiler_version) >= "15": - return "14.1" - else: - return "%s.0" % compiler_version return "" @property From 747d9a65e7589369534d72664ad5637ce02a6adc Mon Sep 17 00:00:00 2001 From: "Kevin A. Mitchell" Date: Mon, 23 Aug 2021 22:30:10 -0500 Subject: [PATCH 4/4] boost: Fix choice of using tools.vcvars(). Use tools.vcvars() unless the user specified a toolset manually. --- recipes/boost/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/boost/all/conanfile.py b/recipes/boost/all/conanfile.py index 9d6e73f93cff6..af5a831c37692 100644 --- a/recipes/boost/all/conanfile.py +++ b/recipes/boost/all/conanfile.py @@ -815,9 +815,9 @@ def build(self): full_command += ' --debug-configuration --build-dir="%s"' % self.build_folder self.output.warn(full_command) - # If sending a toolset to B2, setting the vcvars interferes with the compiler - # selection. - use_vcvars = self._is_msvc and not self._msvc_toolset + # If sending a user-specified toolset to B2, setting the vcvars + # interferes with the compiler selection. + use_vcvars = self._is_msvc and not self.settings.compiler.get_safe("toolset", default="") with tools.vcvars(self.settings) if use_vcvars else tools.no_op(): with tools.chdir(sources): # To show the libraries *1