1from conans import ConanFile
2from conans.tools import os_info
3from conans.model.version import Version
4
5class Exiv2Conan(ConanFile):
6    settings = 'os', 'compiler', 'build_type', 'arch'
7    generators = 'cmake'
8    options = {'unitTests': [True, False],
9               'xmp': [True, False],
10               'iconv': [True, False],
11               'webready': [True, False],
12              }
13    default_options = ('unitTests=True',
14                       'xmp=False',
15                       'iconv=False',
16                       'webready=False',
17                      )
18
19    def configure(self):
20        self.options['libcurl'].shared = False
21        self.options['libcurl'].with_openssl = True
22        self.options['gtest'].shared = True
23
24    def requirements(self):
25        self.requires('zlib/1.2.11@conan/stable')
26
27        if os_info.is_windows and self.options.iconv:
28            self.requires('libiconv/1.15@bincrafters/stable')
29
30        if self.options.unitTests:
31            if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version.value) <= "12":
32                self.requires('gtest/1.8.0@bincrafters/stable')
33            else:
34                self.requires('gtest/1.8.1@bincrafters/stable')
35
36        if self.options.webready and not os_info.is_macos:
37            # Note: This difference in versions is just due to a combination of corner cases in the
38            # recipes and the OS & compiler versions used in Travis and AppVeyor. In normal cases we
39            # could use any of the versions.Also note that the issue was not with libcurl but with
40            # libopenssl (a transitive dependency)
41            if os_info.is_windows:
42                self.requires('libcurl/7.69.1')
43                self.options['libcurl'].with_openssl = False
44                self.options['libcurl'].with_winssl = True
45            else:
46                self.requires('libcurl/7.64.1@bincrafters/stable')
47
48        if self.options.xmp:
49            self.requires('XmpSdk/2016.7@piponazo/stable') # from conan-piponazo
50        else:
51            self.requires('Expat/2.2.6@pix4d/stable')
52
53    def imports(self):
54        self.copy('*.dll', dst='conanDlls', src='bin')
55        self.copy('*.dylib', dst='bin', src='lib')
56