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

[boost] get rid of compiler version in user config #1093

Merged
merged 4 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 40 additions & 50 deletions recipes/boost/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ def _build_bcp(self):
folder = os.path.join(self.source_folder, self._folder_name, 'tools', 'bcp')
with tools.vcvars(self.settings) if self._is_msvc else tools.no_op():
with tools.chdir(folder):
toolset, _, _ = self._toolset_version_and_exe
command = "%s -j%s --abbreviate-paths -d2 toolset=%s" % (self._b2_exe, tools.cpu_count(), toolset)
command = "%s -j%s --abbreviate-paths -d2 toolset=%s" % (self._b2_exe, tools.cpu_count(), self._toolset)
self.output.warn(command)
self.run(command)

Expand Down Expand Up @@ -567,8 +566,7 @@ def add_defines(option, library):
if getattr(self.options, "without_%s" % libname):
flags.append("--without-%s" % libname)

toolset, _, _ = self._toolset_version_and_exe
flags.append("toolset=%s" % toolset)
flags.append("toolset=%s" % self._toolset)

if self.settings.get_safe("compiler.cppstd"):
flags.append("cxxflags=%s" % cppstd_flag(
Expand Down Expand Up @@ -686,14 +684,18 @@ def _cxx(self):
return os.environ["CXX"]
if tools.is_apple_os(self.settings.os) and self.settings.compiler == "apple-clang":
return tools.XCRun(self.settings).cxx
return None
compiler_version = str(self.settings.compiler.version)
major = compiler_version.split(".")[0]
if self.settings.compiler == "gcc":
return tools.which("g++-%s" % compiler_version) or tools.which("g++-%s" % major) or tools.which("g++") or ""
if self.settings.compiler == "clang":
return tools.which("clang++-%s" % compiler_version) or tools.which("clang++-%s" % major) or tools.which("clang++") or ""
return ""

def _create_user_config_jam(self, folder):
"""To help locating the zlib and bzip2 deps"""
self.output.warn("Patching user-config.jam")

compiler_command = self._cxx

contents = ""
if self._zip_bzip2_requires_needed:
def create_library_config(name):
Expand Down Expand Up @@ -728,12 +730,9 @@ def create_library_config(name):
includes=self._python_includes,
libraries=self._python_libraries)

toolset, version, exe = self._toolset_version_and_exe
exe = compiler_command or exe # Prioritize CXX

# Specify here the toolset with the binary if present if don't empty parameter : :
contents += '\nusing "%s" : "%s" : ' % (toolset, version)
contents += ' %s' % exe.replace("\\", "/")
# Specify here the toolset with the binary if present if don't empty parameter :
contents += '\nusing "%s" : %s : ' % (self._toolset, self._toolset_version)
contents += ' %s' % self._cxx.replace("\\", "/")

if tools.is_apple_os(self.settings.os):
if self.settings.compiler == "apple-clang":
Expand Down Expand Up @@ -762,52 +761,43 @@ def create_library_config(name):
tools.save(filename, contents)

@property
def _toolset_version_and_exe(self):
compiler_version = str(self.settings.compiler.version)
major = compiler_version.split(".")[0]
if "." not in compiler_version:
compiler_version += ".0"
compiler = str(self.settings.compiler)
def _toolset_version(self):
if self._is_msvc:
compiler_version = str(self.settings.compiler.version)
if Version(compiler_version) >= "16":
_msvc_version = "14.2"
return "14.2"
elif Version(compiler_version) >= "15":
_msvc_version = "14.1"
else:
_msvc_version = compiler_version
return "msvc", _msvc_version, ""
elif self.settings.os == "Windows" and self.settings.compiler == "clang":
return "clang-win", compiler_version, ""
elif self.settings.os == "Emscripten" and self.settings.compiler == "clang":
return "emscripten", compiler_version, self._cxx
elif self.settings.compiler == "gcc" and tools.is_apple_os(self.settings.os):
return "darwin", compiler_version, self._cxx
elif compiler == "gcc" and Version(major) >= "5":
# For GCC >= v5 we only need the major otherwise Boost doesn't find the compiler
# The NOT windows check is necessary to exclude MinGW:
if not tools.which("g++-%s" % major):
# In fedora 24, 25 the gcc is 6, but there is no g++-6 and the detection is 6.3.1
# so b2 fails because 6 != 6.3.1. Specify the exe to avoid the smart detection
executable = tools.which("g++") or ""
return "14.1"
SSE4 marked this conversation as resolved.
Show resolved Hide resolved
else:
executable = ""
return compiler, compiler_version, executable
elif self.settings.compiler == "apple-clang":
return "clang-darwin", compiler_version, self._cxx
elif self.settings.os == "Android" and self.settings.compiler == "clang":
return "clang-linux", compiler_version, self._cxx
return "%s.0" % compiler_version
return ""

@property
def _toolset(self):
compiler = str(self.settings.compiler)
if self._is_msvc:
return "msvc"
elif self.settings.os == "Windows" and compiler == "clang":
return "clang-win"
elif self.settings.os == "Emscripten" and compiler == "clang":
return "emscripten"
elif compiler == "gcc" and tools.is_apple_os(self.settings.os):
return "darwin"
elif compiler == "apple-clang":
return "clang-darwin"
elif self.settings.os == "Android" and compiler == "clang":
return "clang-linux"
elif str(self.settings.compiler) in ["clang", "gcc"]:
# For GCC < v5 and Clang we need to provide the entire version string
return compiler, compiler_version, ""
elif self.settings.compiler == "sun-cc":
return "sunpro", compiler_version, ""
elif self.settings.compiler == "intel":
return compiler
elif compiler == "sun-cc":
return "sunpro"
elif compiler == "intel":
toolset = {"Macos": "intel-darwin",
"Windows": "intel-win",
"Linux": "intel-linux"}.get(str(self.settings.os))
return toolset, compiler_version, ""
return toolset
else:
return compiler, compiler_version, ""
return compiler

##################### BOOSTRAP METHODS ###########################
@property
Expand Down
2 changes: 1 addition & 1 deletion recipes/boost/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PROJECT(MyHello)
cmake_minimum_required(VERSION 2.8)
project(test_package)
enable_testing()

set(Boost_DEBUG 1)
Expand Down