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 15, 2024
1 parent 14fa98a commit dd401f2
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 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,11 @@ def generate(self):
env.generate(scope="build")

tc = AutotoolsToolchain(self)
tc.configure_args.append("--with-gmp" if self.options.with_gmp else "--without-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(self, 180, raise_invalid=False):
tc.extra_cflags.append("-FS")
tc.generate()

if is_msvc(self):
Expand All @@ -91,6 +97,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 dd401f2

Please sign in to comment.