Skip to content

Commit

Permalink
(#19150) [mpfr] Fix when building shared library on Linux
Browse files Browse the repository at this point in the history
Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries authored Aug 11, 2023
1 parent f4635a5 commit 78976dd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions recipes/mpfr/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps
from conan.tools.microsoft import is_msvc, check_min_vs, unix_path
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.env import VirtualRunEnv
from conan.tools.build import cross_building
from conan.errors import ConanException
import os
import re
Expand Down Expand Up @@ -73,6 +75,9 @@ def source(self):
destination=self.source_folder, strip_root=True)

def generate(self):
if not cross_building(self):
env = VirtualRunEnv(self)
env.generate(scope="build")
if self.settings.os == "Windows":
if is_msvc(self) and not check_min_vs(self, 193, raise_invalid=False) and \
not self.conf.get("tools.cmake.cmaketoolchain:generator", check_type=str):
Expand Down Expand Up @@ -126,9 +131,8 @@ def _extract_mpfr_autotools_variables(self):
defs = self._extract_makefile_variable(makefile, "DEFS")
return sources, headers, defs

def build(self):
def _patch_sources(self):
apply_conandata_patches(self)

if self.settings.os == "Windows": # Allow mixed shared and static libs
replace_in_file(self, os.path.join(self.source_folder, "configure"),
'as_fn_error $? "libgmp isn\'t provided as a DLL: use --enable-static --disable-shared" "$LINENO" 5',
Expand All @@ -144,6 +148,8 @@ def build(self):
"<gmp.h>", "<mpir.h>")
save(self, "gmp.h", "#pragma once\n#include <mpir.h>\n")

def build(self):
self._patch_sources()
autotools = Autotools(self)
autotools.configure() # Need to generate Makefile to extract variables for CMake below

Expand Down

0 comments on commit 78976dd

Please sign in to comment.