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

Fix boost fPIC management #5071

Merged
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
39 changes: 26 additions & 13 deletions recipes/boost/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,21 @@ def config_options(self):
def _configure_options(self):
return self._dependencies["configure_options"]

@property
def _fPIC(self):
return self.options.get_safe("fPIC", self.default_options["fPIC"])

@property
def _shared(self):
return self.options.get_safe("shared", self.default_options["shared"])

def configure(self):
if self.options.header_only:
del self.options.shared
del self.options.fPIC
elif self.options.shared:
del self.options.fPIC

if self.options.without_locale:
self.options.i18n_backend = None
else:
Expand All @@ -267,11 +281,11 @@ def configure(self):
if not self.options.get_safe('without_%s' % lib):
raise ConanInvalidConfiguration("Boost '%s' library requires multi threading" % lib)

if self.settings.compiler == "Visual Studio" and "MT" in str(self.settings.compiler.runtime) and self.options.shared:
raise ConanInvalidConfiguration("Boost can not be built as shared library with MT runtime.")

if self.settings.compiler == "Visual Studio" and self.options.shared and self.options.numa:
raise ConanInvalidConfiguration("Cannot build a shared boost with numa support on Visual Studio")
if self.settings.compiler == "Visual Studio" and self._shared:
if "MT" in str(self.settings.compiler.runtime):
raise ConanInvalidConfiguration("Boost can not be built as shared library with MT runtime.")
if self.options.numa:
raise ConanInvalidConfiguration("Cannot build a shared boost with numa support on Visual Studio")

# Check, when a boost module is enabled, whether the boost modules it depends on are enabled as well.
for mod_name, mod_deps in self._dependencies["dependencies"].items():
Expand Down Expand Up @@ -808,7 +822,7 @@ def add_defines(library):
flags.append("threading=%s" % ("single" if not self.options.multithreading else "multi" ))
flags.append("visibility=%s" % self.options.visibility)

flags.append("link=%s" % ("static" if not self.options.shared else "shared"))
flags.append("link=%s" % ("shared" if self._shared else "static"))
if self.settings.build_type == "Debug":
flags.append("variant=debug")
else:
Expand All @@ -829,9 +843,8 @@ def add_defines(library):
# CXX FLAGS
cxx_flags = []
# fPIC DEFINITION
if self.settings.os != "Windows":
if self.options.fPIC:
cxx_flags.append("-fPIC")
if self._fPIC:
cxx_flags.append("-fPIC")
if self.settings.build_type == "RelWithDebInfo":
if self.settings.compiler == "gcc" or "clang" in str(self.settings.compiler):
cxx_flags.append("-g")
Expand Down Expand Up @@ -1101,7 +1114,7 @@ def package(self):
if self.settings.os == "Emscripten":
self._create_emscripten_libs()

if self._is_msvc and self.options.shared:
if self._is_msvc and self._shared:
# Some boost releases contain both static and shared variants of some libraries (if shared=True)
all_libs = set(tools.collect_libs(self, "lib"))
static_libs = set(l for l in all_libs if l.startswith("lib"))
Expand Down Expand Up @@ -1219,7 +1232,7 @@ def package_info(self):
self.cpp_info.components["dynamic_linking"].names["cmake_find_package_multi"] = "dynamic_linking"
self.cpp_info.components["dynamic_linking"].names["pkg_config"] = "boost_dynamic_linking" # FIXME: disable on pkg_config
self.cpp_info.components["_libboost"].requires.append("dynamic_linking")
if self.options.shared:
if self._shared:
# A Boost::dynamic_linking cmake target does only make sense for a shared boost package
self.cpp_info.components["dynamic_linking"].defines = ["BOOST_ALL_DYN_LINK"]

Expand Down Expand Up @@ -1273,7 +1286,7 @@ def package_info(self):
def add_libprefix(n):
""" On MSVC, static libraries are built with a 'lib' prefix. Some libraries do not support shared, so are always built as a static library. """
libprefix = ""
if self.settings.compiler == "Visual Studio" and (not self.options.shared or n in self._dependencies["static_only"]):
if self.settings.compiler == "Visual Studio" and (not self._shared or n in self._dependencies["static_only"]):
libprefix = "lib"
return libprefix + n

Expand Down Expand Up @@ -1343,7 +1356,7 @@ def filter_transform_module_libraries(names):
if not self.options.without_python:
pyversion = tools.Version(self._python_version)
self.cpp_info.components["python{}{}".format(pyversion.major, pyversion.minor)].requires = ["python"]
if not self.options.shared:
if not self._shared:
self.cpp_info.components["python"].defines.append("BOOST_PYTHON_STATIC_LIB")

self.cpp_info.components["numpy{}{}".format(pyversion.major, pyversion.minor)].requires = ["numpy"]
Expand Down
2 changes: 1 addition & 1 deletion recipes/boost/all/rebuild-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def do_boostdep_collect(self) -> BoostDependencies:

dependency_tree = {}
buildable_dependencies = subprocess.check_output(["boostdep", "--list-buildable-dependencies"], text=True)
log.debug("boosdep --list-buildable-dependencies returnes: %s", buildable_dependencies)
log.debug("boostdep --list-buildable-dependencies returns: %s", buildable_dependencies)
for line in buildable_dependencies.splitlines():
if re.match(r"^[\s]*#.*", line):
continue
Expand Down