Skip to content

Commit

Permalink
(#5119) [boost] For Visual Studio, pass some values of settings.compi…
Browse files Browse the repository at this point in the history
…ler.toolset to B2

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

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

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

* boost: Fix choice of using tools.vcvars().

Use tools.vcvars() unless the user specified a toolset manually.
  • Loading branch information
datalogics-kam authored Oct 9, 2021
1 parent 17906c6 commit f7e314e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions recipes/boost/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from conans.errors import ConanInvalidConfiguration
import glob
import os
import re
import sys
import shlex
import shutil
Expand Down Expand Up @@ -814,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 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
# self.run("%s --show-libraries" % b2_exe)
Expand Down Expand Up @@ -1224,13 +1228,10 @@ def create_library_config(deps_name, name):
@property
def _toolset_version(self):
if self._is_msvc:
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
toolset = tools.msvs_toolset(self)
match = re.match(r'v(\d+)(\d)$', toolset)
if match:
return "%s.%s" % (match.group(1), match.group(2))
return ""

@property
Expand Down

0 comments on commit f7e314e

Please sign in to comment.