from conans import ConanFile, CMake
import urllib3
import tarfile

class FltkConan(ConanFile):
    name = "FLTK"
    version = "1.3.4"
    license = "GNU LGPL with exceptions (http://www.fltk.org/COPYING.php)"
    url = "https://github.com/trigger-happy/conan-packages"
    description = "FLTK widget library for C++"
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False]}
    default_options = "shared=False"
    generators = "cmake"

    def source(self):
        fileName = 'fltk-{0}-1-source.tar.gz'.format(self.version)
        sourceUrl = 'http://fltk.org/pub/fltk/1.3.4/fltk-{0}-1-source.tar.gz'.format(self.version)
        pool = urllib3.PoolManager()
        request = pool.request('GET', sourceUrl)
        if request.status == 200:
            f = open(fileName, 'w')
            f.write(request.data)
            f.close()
            tf = tarfile.open(fileName)
            tf.extractall('.')
            tf.close()
        else:
            raise Exception('Could not download source file')

    def build(self):
        cmake = CMake(self.settings)
        shared = "-DBUILD_SHARED_LIBS=ON" if self.options.shared else ""
        self.run('cmake fltk-1.3.4-1 %s %s' % (cmake.command_line, shared))
        self.run("cmake --build . %s" % cmake.build_config)

    def package(self):
        self.copy("FL", dst="include", src="fltk-1.3.4-1")
        self.copy("lib/*", dst="lib", keep_path=False)
        self.copy("bin/fluid", dst="bin", keep_path=False)
        self.copy("bin/fltk-config", dst="bin", keep_path=False)

    def package_info(self):
        self.cpp_info.libs = ["fltk", "fltk_images", "fltk_gl", "fltk_forms"]

@@ -1039,16 +1039,668 @@
 file')%0A%0A
+    def configure(self):%0A        self.requires(%22libxdmcp/1.1.2@trigger-happy/stable%22)%0A        self.requires(%22libxau/1.0.8@trigger-happy/stable%22)%0A        self.requires(%22libxcb/1.12@trigger-happy/stable%22)%0A        self.requires(%22pcre/8.40.0@kmaragon/stable%22)%0A        self.requires(%22graphite/1.3.10@trigger-happy/stable%22)%0A        self.options%5B%22libxdmcp/1.1.2%22%5D.shared = self.options.shared%0A        self.options%5B%22libxau/1.0.8%22%5D.shared = self.options.shared%0A        self.options%5B%22libxcb/1.12%22%5D.shared = self.options.shared%0A        self.options%5B%22pcre/8.40.0%22%5D.shared = self.options.shared%0A        self.options%5B%22graphite/1.3.10%22%5D.shared = self.options.shared%0A%0A
     def 

Add package requirements for FLTK