forked from bincrafters/conan-libtiff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
94 lines (80 loc) · 4.45 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
import os
import shutil
class LibtiffConan(ConanFile):
name = "libtiff"
description = "Library for Tag Image File Format (TIFF)"
version = "4.0.9"
url = "http://github.com/bincrafters/conan-tiff"
author = "Bincrafters <[email protected]>"
license = "MIT"
homepage = "http://www.simplesystems.org/libtiff"
exports = ["LICENSE.md"]
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {'shared': False, 'fPIC': True}
requires = "zlib/1.2.11@conan/stable"
_source_subfolder = "source_subfolder"
def config_options(self):
if self.settings.os == "Windows":
self.options.remove("fPIC")
del self.settings.compiler.libcxx
def source(self):
tools.get("http://download.osgeo.org/libtiff/tiff-{0}.zip".format(self.version))
os.rename('tiff-' + self.version, self._source_subfolder)
os.rename(os.path.join(self._source_subfolder, "CMakeLists.txt"),
os.path.join(self._source_subfolder, "CMakeListsOriginal.txt"))
shutil.copy("CMakeLists.txt",
os.path.join(self._source_subfolder, "CMakeLists.txt"))
def build(self):
cmake = CMake(self)
cmake.definitions['CMAKE_INSTALL_LIBDIR'] = 'lib'
cmake.definitions['CMAKE_INSTALL_BINDIR'] = 'bin'
cmake.definitions['CMAKE_INSTALL_INCLUDEDIR'] = 'include'
cmake.definitions["lzma"] = False
cmake.definitions["jpeg"] = False
cmake.definitions["jbig"] = False
if self.options.shared and self.settings.compiler == "Visual Studio":
# https://github.com/Microsoft/vcpkg/blob/master/ports/tiff/fix-cxx-shared-libs.patch
tools.replace_in_file(os.path.join(self._source_subfolder, 'libtiff', 'CMakeLists.txt'),
r'set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION})',
r'set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION} '
r'WINDOWS_EXPORT_ALL_SYMBOLS ON)')
if self.settings.os == "Windows" and self.settings.compiler != "Visual Studio":
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeListsOriginal.txt"),
"find_library(M_LIBRARY m)",
"if (NOT MINGW)\n find_library(M_LIBRARY m)\nendif()")
if self.version == '4.0.8':
# only one occurence must be patched. fixed in 4.0.9
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeListsOriginal.txt"),
"if (UNIX)",
"if (UNIX OR MINGW)")
cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared
cmake.configure(source_folder=self._source_subfolder)
cmake.build()
cmake.install()
def package(self):
self.copy("COPYRIGHT", src=self._source_subfolder, dst="licenses", ignore_case=True, keep_path=False)
shutil.rmtree(os.path.join(self.package_folder, 'share', 'man'), ignore_errors=True)
shutil.rmtree(os.path.join(self.package_folder, 'share', 'doc'), ignore_errors=True)
# remove binaries
for bin_program in ['fax2ps', 'fax2tiff', 'pal2rgb', 'ppm2tiff', 'raw2tiff', 'tiff2bw', 'tiff2pdf',
'tiff2ps', 'tiff2rgba', 'tiffcmp', 'tiffcp', 'tiffcrop', 'tiffdither', 'tiffdump',
'tiffgt', 'tiffinfo', 'tiffmedian', 'tiffset', 'tiffsplit']:
for ext in ['', '.exe']:
try:
os.remove(os.path.join(self.package_folder, 'bin', bin_program+ext))
except:
pass
def package_info(self):
self.cpp_info.libs = ["tiff", "tiffxx"]
if self.settings.os == "Windows" and self.settings.build_type == "Debug" and self.settings.compiler == 'Visual Studio':
self.cpp_info.libs = [lib+'d' for lib in self.cpp_info.libs]
if self.options.shared and self.settings.os == "Windows" and self.settings.compiler != 'Visual Studio':
self.cpp_info.libs = [lib+'.dll' for lib in self.cpp_info.libs]
if self.settings.os == "Linux":
self.cpp_info.libs.append("m")