-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
124 lines (98 loc) · 4.59 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from conans import AutoToolsBuildEnvironment, ConanFile, tools, RunEnvironment
from conans.tools import PkgConfig
from conans.errors import ConanInvalidConfiguration
import os
class IpoptConan(ConanFile):
name = "ipopt"
# version = "3.13.4"
license = ("EPL-2.0",)
author = "SINTEF Ocean"
url = "https://github.com/sintef-ocean/conan-ipopt"
homepage = "https://github.com/coin-or/Ipopt"
description =\
"Ipopt (Interior Point OPTimizer) is a" \
" software package for large-scale nonlinear optimization."
topics = ("Nonlinear optimization", "COIN-OR")
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_hsl": [True, False]
}
default_options = {
"shared": True,
"fPIC": True,
"with_hsl": False
}
generators = "pkg_config"
build_requires = ("coinbrew/2021.01@sintef/stable")
_name = "Ipopt"
def requirements(self):
if self.options.with_hsl:
self.requires("coinhsl/[>=2014.01.17]@sintef/stable")
if self.settings.compiler == "Visual Studio":
self.requires("openblas/[>=0.3.13]@sintef/testing")
else:
self.requires("coinmumps/4.10.0@sintef/stable")
self.requires("openblas/[>=0.3.13]")
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC # is this an option with mingw?
def configure(self):
if self.settings.compiler == "Visual Studio":
raise ConanInvalidConfiguration(
"This recipe is does not support Visual Studio")
self.options["openblas"].shared = self.options.shared
self.options["openblas"].build_lapack = True
# self.options["openblas"].use_thread = True
# self.options["openblas"].dynamic_arch = True
def source(self):
self.run(
"coinbrew fetch {}@{} --option ".format(self._name, self.version) +
"--skip-dependencies")
def build(self):
env_build = AutoToolsBuildEnvironment(self)
environ = env_build.vars.copy()
environ["PKG_CONFIG_PATH"] = self.build_folder
env_build_run = RunEnvironment(self) # Needed for runtime tests
with tools.environment_append(env_build_run.vars):
with tools.environment_append(environ):
cmd_str = str()
cmd_str += "coinbrew build {}@{} ".format(self._name, self.version)
cmd_str += "--no-prompt "
cmd_str += "--skip-dependencies "
cmd_str += "--verbosity=4 "
cmd_str += "--parallel-jobs {} ".format(tools.cpu_count())
if not self.settings.os == "Windows" and not self.options.shared:
cmd_str += "--static "
# --enable-static
# --enable-shared
if self.settings.build_type == "Debug":
cmd_str += "--enable-debug "
if self.settings.compiler == "Visual Studio":
cmd_str += "--enable-msvc={} ".format(self.settings.compiler.runtime)
if self.options.fPIC:
cmd_str += "--with-pic "
pkg_openblas = PkgConfig("openblas")
pkg_mumps = PkgConfig("coinmumps")
cmd_str += "--with-lapack=\"{}\" ".format(" ".join(pkg_openblas.libs))
cmd_str += "--with-mumps=\"{}\" ".format(" ".join(pkg_mumps.libs))
cmd_str += "--with-mumps-cflags=\"{}\" ".format(" ".join(pkg_mumps.cflags))
if self.options.with_hsl:
pkg_coinhsl = PkgConfig("coinhsl")
cmd_str += "--with-hsl=\"{}\" ".format(" ".join(pkg_coinhsl.libs))
cmd_str += "--with-hsl-cflags=\"{}\" ".format(" ".join(pkg_coinhsl.cflags))
self.run(cmd_str)
def package(self):
self.copy("*", src="dist")
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
os.unlink(os.path.join(self.package_folder, "lib", "libipopt.la"))
os.unlink(os.path.join(self.package_folder, "lib", "libsipopt.la"))
def package_info(self):
self.cpp_info.names["cmake_find_package"] = "IPOPT"
self.cpp_info.libs = ["ipopt", "sipopt"]
self.cpp_info.includedirs = [os.path.join("include", "coin-or")]
# TODO: add system_libs dependencies, pthread,
# gomp1, omp5, gfortran{3,4,5} or other openmp/fortran runtimes
def imports(self):
self.copy("license*", dst="licenses", folder=True, ignore_case=True)