Skip to content

Commit

Permalink
glpk: add gmp support
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Apr 14, 2024
1 parent 14fa98a commit 35f4a21
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions recipes/glpk/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
from conan.tools.build import cross_building
from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv
from conan.tools.files import copy, get, rename, rm
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, unix_path
from conan.tools.scm import Version
from conan.tools.microsoft import is_msvc, unix_path, check_min_vs
import os

required_conan_version = ">=1.54.0"
Expand All @@ -24,10 +23,12 @@ class GlpkConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_gmp": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_gmp": True,
}

@property
Expand All @@ -47,8 +48,14 @@ def configure(self):
def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
if self.options.with_gmp:
self.requires("gmp/6.3.0")

def build_requirements(self):
self.tool_requires("libtool/2.4.7")
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/2.1.0")
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
Expand All @@ -68,12 +75,12 @@ def generate(self):
env.generate(scope="build")

tc = AutotoolsToolchain(self)
yes_no = lambda v: "yes" if v else "no"
tc.configure_args.append(f"--with-gmp={yes_no(self.options.with_gmp)}")
if is_msvc(self):
tc.extra_defines.append("__WOE__")
if (Version(conan_version).major < "2" and self.settings.compiler == "Visual Studio" \
and Version(self.settings.compiler.version) >= "12") or \
(self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"):
tc.extra_cflags.append("-FS")
if check_min_vs(180, raise_invalid=False):

Check failure on line 82 in recipes/glpk/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

No value for argument 'version' in function call
tc.extra_cflags.append("-FS")
tc.generate()

if is_msvc(self):
Expand All @@ -91,6 +98,9 @@ def generate(self):
env.define("STRIP", ":")
env.vars(self).save_script("conanbuild_msvc")

deps = PkgConfigDeps(self)
deps.generate()

def build(self):
autotools = Autotools(self)
autotools.autoreconf()
Expand Down

0 comments on commit 35f4a21

Please sign in to comment.