-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
93 lines (79 loc) · 3.98 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
from conans import ConanFile, ConfigureEnvironment
import os
from conans.tools import download, unzip, replace_in_file
from conans import CMake
from shutil import copyfile
class ZlibNgConan(ConanFile):
name = "littlecms"
version = "2.7"
ZIP_FOLDER_NAME = "lcms2-%s" % version
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = "shared=False", "fPIC=True"
exports = ["CMakeLists.txt"]
url="http://github.com/lasote/conan-littlecms"
license="https://github.com/mm2/Little-CMS/blob/master/COPYING"
def config(self):
try: # Try catch can be removed when conan 0.8 is released
del self.settings.compiler.libcxx
except:
pass
if self.settings.os == "Windows":
self.options.remove("fPIC")
def source(self):
zip_name = "lcms2-%s.tar.gz" % self.version
download("http://downloads.sourceforge.net/project/lcms/lcms/2.7/%s" % zip_name, zip_name)
unzip(zip_name)
os.unlink(zip_name)
if self.settings.os != "Windows":
self.run("chmod +x ./%s/configure" % self.ZIP_FOLDER_NAME)
else:
copyfile("CMakeLists.txt", os.path.join(self.ZIP_FOLDER_NAME, "CMakeLists.txt"))
def build(self):
""" Define your project building. You decide the way of building it
to reuse it later in any other project.
"""
if self.settings.os == "Linux" or self.settings.os == "Macos":
if self.settings.os == "Macos":
old_str = 'install_name \$rpath/\$soname'
new_str = 'install_name \$soname'
replace_in_file("./%s/configure" % self.ZIP_FOLDER_NAME, old_str, new_str)
env = ConfigureEnvironment(self.deps_cpp_info, self.settings)
if self.options.fPIC:
env_line = env.command_line.replace('CFLAGS="', 'CFLAGS="-fPIC ')
else:
env_line = env.command_line
self.run("cd %s && %s ./configure" % (self.ZIP_FOLDER_NAME, env_line))
self.run("cd %s && %s make" % (self.ZIP_FOLDER_NAME, env_line))
else:
cmake = CMake(self.settings)
self.run("cd %s && mkdir _build" % self.ZIP_FOLDER_NAME)
cd_build = "cd %s/_build" % self.ZIP_FOLDER_NAME
self.output.warn('%s && cmake .. %s' % (cd_build, cmake.command_line))
shared_line = "-DBUILD_SHARED_LIBS=ON" if self.options.shared else ""
self.run('%s && cmake .. %s %s' % (cd_build, cmake.command_line, shared_line))
self.output.warn("%s && cmake --build . %s" % (cd_build, cmake.build_config))
self.run("%s && cmake --build . %s" % (cd_build, cmake.build_config))
def package(self):
""" Define your conan structure: headers, libs, bins and data. After building your
project, this method is called to create a defined structure:
"""
self.copy("*.h", "include", "%s" % (self.ZIP_FOLDER_NAME), keep_path=False)
self.copy("*.h", "include", "%s" % ("_build"), keep_path=False)
if self.settings.os == "Windows":
self.copy(pattern="*lcms2.lib", dst="lib", src="", keep_path=False)
self.copy(pattern="*.dll", dst="bin", src=os.path.join(self.ZIP_FOLDER_NAME, "_build"), keep_path=False)
else:
if self.options.shared:
if self.settings.os == "Macos":
self.copy(pattern="*.dylib", dst="lib", keep_path=False)
else:
self.copy(pattern="*.so*", dst="lib", src=self.ZIP_FOLDER_NAME, keep_path=False)
else:
self.copy(pattern="*.a", dst="lib", src=self.ZIP_FOLDER_NAME, keep_path=False)
def package_info(self):
if self.settings.os == "Windows":
self.cpp_info.libs = ['lcms2']
else:
self.cpp_info.libs = ['lcms2', 'm']