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

coin-cgl: add 0.60.8, apply autoreconf, add GLPK support #23535

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 3 additions & 7 deletions recipes/coin-cgl/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"0.60.8":
url: "https://github.com/coin-or/Cgl/archive/releases/0.60.8.tar.gz"
sha256: "1482ba38afb783d124df8d5392337f79fdd507716e9f1fb6b98fc090acd1ad96"
"0.60.7":
url: "https://github.com/coin-or/Cgl/archive/releases/0.60.7.tar.gz"
sha256: "93b30a80b5d2880c2e72d5877c64bdeaf4d7c1928b3194ea2f88b1aa4517fb1b"
Expand All @@ -8,10 +11,3 @@ sources:
"0.60.3":
url: "https://github.com/coin-or/Cgl/archive/refs/tags/releases/0.60.3.tar.gz"
sha256: "cfeeedd68feab7c0ce377eb9c7b61715120478f12c4dd0064b05ad640e20f3fb"
patches:
"0.60.7":
- patch_file: "patches/0.60.6-0001-no-pkg-config-check.patch"
"0.60.6":
- patch_file: "patches/0.60.6-0001-no-pkg-config-check.patch"
"0.60.3":
- patch_file: "patches/0.60.3-0001-no-pkg-config-check.patch"
78 changes: 43 additions & 35 deletions recipes/coin-cgl/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.build import cross_building
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, rm, rmdir
from conan.tools.files import copy, get, rename, rm, rmdir
from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.microsoft import check_min_vs, is_msvc, msvc_runtime_flag, unix_path
import os
import shutil

required_conan_version = ">=1.57.0"

Expand All @@ -24,19 +23,18 @@ class CoinCglConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_glpk": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_glpk": True,
}

@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)

def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Expand All @@ -49,27 +47,23 @@ def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("coin-utils/2.11.9")
self.requires("coin-osi/0.108.7")
self.requires("coin-clp/1.17.7")
self.requires("coin-utils/2.11.11")
self.requires("coin-osi/0.108.10")
self.requires("coin-clp/1.17.9")
if self.options.with_glpk:
self.requires("glpk/4.48")
# BLAS and LAPACK are not used
# TODO: add support for: Cplex, Mosek, Xpress, Vol, DyLP

def build_requirements(self):
self.tool_requires("coin-buildtools/0.8.11")
self.tool_requires("gnu-config/cci.20210814")
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/2.0.3")
self.tool_requires("pkgconf/[>=2.2 <3]")
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
if is_msvc(self):
self.tool_requires("automake/1.16.5")

def validate(self):
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration("coin-cgl does not support shared builds on Windows")
# FIXME: This issue likely comes from very old autotools versions used to produce configure.
if hasattr(self, "settings_build") and cross_building(self) and self.options.shared:
raise ConanInvalidConfiguration("coin-cgl shared not supported yet when cross-building")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
Expand All @@ -78,10 +72,28 @@ def generate(self):
env = VirtualBuildEnv(self)
env.generate()

deps = PkgConfigDeps(self)
deps.generate()

def _add_pkg_config_alias(src_name, dst_name):
shutil.copy(os.path.join(self.generators_folder, f"{src_name}.pc"),
os.path.join(self.generators_folder, f"{dst_name}.pc"))

if self.options.with_glpk:
_add_pkg_config_alias("glpk", "coinglpk")

tc = AutotoolsToolchain(self)
tc.configure_args.extend([
"--without-blas",
"--without-lapack",
"--with-osiglpk" if self.options.with_glpk else "--without-osiglpk",
"--without-vol",
"--without-dylp",
"--without-osicpx",
"--without-osimsk",
"--without-osixpr",
"--without-osivol",
"--without-sample",
"--disable-dependency-linking",
"F77=unavailable",
])
if is_msvc(self):
tc.extra_cxxflags.append("-EHsc")
Expand All @@ -98,29 +110,25 @@ def generate(self):
env.define("LD", f"{compile_wrapper} link -nologo")
env.define("AR", f"{ar_wrapper} \"lib -nologo\"")
env.define("NM", "dumpbin -symbols")
env.define("OBJDUMP", ":")
env.define("RANLIB", ":")
env.define("STRIP", ":")
if self._settings_build.os == "Windows":
# TODO: Something to fix in conan client or pkgconf recipe?
# This is a weird workaround when build machine is Windows. Here we have to inject regular
# Windows path to pc files folder instead of unix path flavor injected by AutotoolsToolchain...
env.define("PKG_CONFIG_PATH", self.generators_folder)
tc.generate(env)

deps = PkgConfigDeps(self)
deps.generate()

def build(self):
apply_conandata_patches(self)
if not is_msvc(self):
for gnu_config in [
self.conf.get("user.gnu-config:config_guess", check_type=str),
self.conf.get("user.gnu-config:config_sub", check_type=str),
]:
if gnu_config:
copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder)
copy(self, "*", os.path.join(self.dependencies.build["coin-buildtools"].package_folder, "res"),
os.path.join(self.source_folder, "BuildTools"))
copy(self, "*", os.path.join(self.dependencies.build["coin-buildtools"].package_folder, "res"),
os.path.join(self.source_folder, "Cgl", "BuildTools"))
for gnu_config in [
self.conf.get("user.gnu-config:config_guess", check_type=str),
self.conf.get("user.gnu-config:config_sub", check_type=str),
]:
copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder)
autotools = Autotools(self)
autotools.autoreconf()
autotools.configure()
autotools.make()

Expand Down
13 changes: 0 additions & 13 deletions recipes/coin-cgl/all/patches/0.60.3-0001-no-pkg-config-check.patch

This file was deleted.

13 changes: 0 additions & 13 deletions recipes/coin-cgl/all/patches/0.60.6-0001-no-pkg-config-check.patch

This file was deleted.

2 changes: 1 addition & 1 deletion recipes/coin-cgl/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def requirements(self):

def build_requirements(self):
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/2.0.3")
self.tool_requires("pkgconf/[>=2.2 <3]")

def build(self):
cmake = CMake(self)
Expand Down
8 changes: 0 additions & 8 deletions recipes/coin-cgl/all/test_v1_package/CMakeLists.txt

This file was deleted.

20 changes: 0 additions & 20 deletions recipes/coin-cgl/all/test_v1_package/conanfile.py

This file was deleted.

2 changes: 2 additions & 0 deletions recipes/coin-cgl/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"0.60.8":
folder: "all"
"0.60.7":
folder: "all"
"0.60.6":
Expand Down