Created
April 19, 2016 20:59
-
-
Save dnikishov/515b14139b35f97bcc4c34ee96aa07e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on lasote/libxml2, which is a C library, so things can go wrong; | |
# It's there only to not block libhdr development. | |
from conans import ConanFile | |
import os, shutil | |
from conans.tools import download, unzip, replace_in_file, check_md5 | |
from conans import CMake, ConfigureEnvironment | |
class LibExiv2Conan(ConanFile): | |
name = "exiv2" | |
version = "0.23" | |
ZIP_FOLDER_NAME = "exiv2-%s" % version | |
generators = "cmake" | |
settings = "os", "compiler", "arch", "build_type" | |
options = {"shared": [True, False]} | |
default_options = "shared=True" | |
exports = ["CMakeLists.txt", "FindExiv2.cmake"] | |
url = "http://exiv2.org" | |
requires = "zlib/1.2.8@lasote/stable" | |
def source(self): | |
zip_name = "exiv2-%s.tar.gz" % self.version | |
download("http://www.exiv2.org/%s" % zip_name, zip_name) | |
unzip(zip_name) | |
os.unlink(zip_name) | |
def config(self): | |
self.options.shared = True | |
self.options["zlib"].shared = True | |
def build(self): | |
env = ConfigureEnvironment(self.deps_cpp_info, self.settings) | |
#env_line = env.command_line.replace('CFLAGS="', 'CFLAGS="-fPIC ') | |
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) | |
# current workaround | |
zlib = "--with-zlib=%s" % self.deps_cpp_info["zlib"].rootpath | |
self.run("cd %s && %s ./configure %s" % (self.ZIP_FOLDER_NAME, env.command_line, zlib)) | |
#self.run("cd %s && %s ./configure" % (self.ZIP_FOLDER_NAME, env.command_line)) | |
self.run("cd %s && %s make" % (self.ZIP_FOLDER_NAME, env.command_line)) | |
def package(self): | |
self.copy("FindExiv2.cmake", ".", ".") | |
self.copy("*.h", "include", "%s/include" % (self.ZIP_FOLDER_NAME), keep_path=True) | |
if self.options.shared: | |
self.copy(pattern="*.so*", dst="lib", src=self.ZIP_FOLDER_NAME, keep_path=False) | |
self.copy(pattern="*.dylib*", dst="lib", src=self.ZIP_FOLDER_NAME, keep_path=False) | |
self.copy(pattern="*.dll*", dst="bin", src=self.ZIP_FOLDER_NAME, keep_path=False) | |
else: | |
self.copy(pattern="*.a", dst="lib", src="%s" % self.ZIP_FOLDER_NAME, keep_path=False) | |
self.copy(pattern="*.lib", dst="lib", src="%s" % self.ZIP_FOLDER_NAME, keep_path=False) | |
def package_info(self): | |
if self.settings.os == "Linux" or self.settings.os == "Macos": | |
self.cpp_info.libs = ['exiv2', 'm'] | |
else: | |
self.cpp_info.libs = ['libexiv2'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment