Skip to content

coin-clp: add v1.17.9, apply autoreconf, use OpenBLAS #23534

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

Closed
wants to merge 6 commits into from
Closed
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
8 changes: 3 additions & 5 deletions recipes/coin-clp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
sources:
"1.17.9":
url: "https://github.com/coin-or/Clp/archive/refs/tags/releases/1.17.9.tar.gz"
sha256: "b02109be54e2c9c6babc9480c242b2c3c7499368cfca8c0430f74782a694a49f"
"1.17.7":
url: "https://github.com/coin-or/Clp/archive/refs/tags/releases/1.17.7.tar.gz"
sha256: "c4c2c0e014220ce8b6294f3be0f3a595a37bef58a14bf9bac406016e9e73b0f5"
"1.17.6":
url: "https://github.com/coin-or/Clp/archive/refs/tags/releases/1.17.6.tar.gz"
sha256: "afff465b1620cfcbb7b7c17b5d331d412039650ff471c4160c7eb24ae01284c9"
patches:
"1.17.7":
- patch_file: "patches/1.17.7-0001-no-pkg-config-check.patch"
"1.17.6":
- patch_file: "patches/1.17.6-0001-no-pkg-config-check.patch"
124 changes: 67 additions & 57 deletions recipes/coin-clp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import shutil

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, mkdir, rename, rm, rmdir
from conan.tools.files import copy, get, mkdir, 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, unix_path
from conan.tools.microsoft import is_msvc, unix_path, msvc_runtime_flag
import os

required_conan_version = ">=1.57.0"
required_conan_version = ">=2.1.0"


class CoinClpConan(ConanFile):
Expand All @@ -29,59 +28,77 @@ class CoinClpConan(ConanFile):
"shared": False,
"fPIC": 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

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
implements = ["auto_shared_fpic"]

def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
# Symbols are exposed https://github.com/conan-io/conan-center-index/pull/16053#issuecomment-1512637106
self.requires("coin-utils/2.11.9", transitive_headers=True, transitive_libs=True)
self.requires("coin-osi/0.108.7", transitive_headers=True)
self.requires("coin-utils/2.11.11", transitive_headers=True, transitive_libs=True)
self.requires("coin-osi/0.108.10", transitive_headers=True)
self.requires("openblas/0.3.28")

def validate(self):
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration("coin-clp 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-clp shared not supported yet when cross-building")
# TODO:
# self.requires("metis/5.2.1")
# self.requires("coin-mumps/3.0.5")
# self.requires("suitesparse-amd/3.3.2")
# self.requires("suitesparse-cholmod/5.2.1")
# Not yet available on CCI: ASL, WSMP

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.1.0")
if self._settings_build.os == "Windows":
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 source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

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"))

_add_pkg_config_alias("openblas", "coinblas")
_add_pkg_config_alias("openblas", "coinlapack")

tc = AutotoolsToolchain(self)
if is_msvc(self) and check_min_vs(self, "180", raise_invalid=False):
tc.extra_cflags.append("-FS")
tc.extra_cxxflags.append("-FS")
tc.configure_args.extend([
# the coin*.pc pkg-config files are only used when set to BUILD
"--with-blas=BUILD",
"--with-lapack=BUILD",
"--with-glpk=no", # GLPK is used as a substitute for AMD, but fails with undefined symbols
# TODO
"--without-asl",
"--without-mumps",
"--without-wsmp",
"--disable-amd-libcheck",
"--disable-cholmod-libcheck",
# These are only used for sample datasets
"--without-netlib",
"--without-sample",
"--disable-dependency-linking",
"F77=unavailable",
])

# TODO: add option
# 1 - build Abc serial but no inherit code
# 2 - build Abc serial and inherit code
# 3 - build Abc cilk parallel but no inherit code
# 4 - build Abc cilk parallel and inherit code
# [AC_HELP_STRING([--enable-aboca],[enables build of Aboca solver (set to 1,2,3,4)])],

if is_msvc(self):
tc.extra_cxxflags.append("-EHsc")
tc.configure_args.append(f"--enable-msvc={msvc_runtime_flag(self)}")
env = tc.environment()
if is_msvc(self):
compile_wrapper = unix_path(self, self.conf.get("user.automake:compile-wrapper", check_type=str))
Expand All @@ -91,29 +108,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":
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, "Clp", "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 All @@ -136,11 +149,8 @@ def package_info(self):
self.cpp_info.components["clp"].set_property("pkg_config_name", "clp")
self.cpp_info.components["clp"].libs = ["ClpSolver", "Clp"]
self.cpp_info.components["clp"].includedirs.append(os.path.join("include", "coin"))
self.cpp_info.components["clp"].requires = ["coin-utils::coin-utils"]
self.cpp_info.components["clp"].requires = ["coin-utils::coin-utils", "openblas::openblas"]

self.cpp_info.components["osi-clp"].set_property("pkg_config_name", "osi-clp")
self.cpp_info.components["osi-clp"].libs = ["OsiClp"]
self.cpp_info.components["osi-clp"].requires = ["clp", "coin-osi::coin-osi"]

# TODO: to remove in conan v2
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
13 changes: 0 additions & 13 deletions recipes/coin-clp/all/patches/1.17.6-0001-no-pkg-config-check.patch

This file was deleted.

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

This file was deleted.

2 changes: 1 addition & 1 deletion recipes/coin-clp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.6)
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(PkgConfig REQUIRED)
Expand Down
7 changes: 3 additions & 4 deletions recipes/coin-clp/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "PkgConfigDeps", "VirtualBuildEnv", "VirtualRunEnv"
test_type = "explicit"
generators = "CMakeToolchain", "PkgConfigDeps"

def layout(self):
cmake_layout(self)
Expand All @@ -17,7 +16,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.1.0")
self.tool_requires("pkgconf/[>=2.2 <3]")

def build(self):
cmake = CMake(self)
Expand All @@ -26,6 +25,6 @@ def build(self):

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
mps = os.path.join(self.source_folder, "sample.mps")
self.run(f"{bin_path} {mps}", env="conanrun")
8 changes: 0 additions & 8 deletions recipes/coin-clp/all/test_v1_package/CMakeLists.txt

This file was deleted.

21 changes: 0 additions & 21 deletions recipes/coin-clp/all/test_v1_package/conanfile.py

This file was deleted.

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