from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout
from conan.tools.scm import Git

class hellotestRecipe(ConanFile):
    name = "hellotest"
    version = "0.0.0"

    license = "ISC"
    author = "Daniel Wolf <nephatrine@gmail.com>"
    url = "https://code.nephatrine.net/nephatrine/hello-test"
    description = "Just a simple Hello World test."

    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False], "fPIC": [True, False]}
    default_options = {"shared": False, "fPIC": True}
    
    exports_sources = "CMakeLists.txt", "src/*", "include/*", "*.md"

    #def source(self):
    #    git = Git(self)
    #    git.clone(url="https://code.nephatrine.net/nephatrine/hello-test.git", target=".")
    #    git.checkout("72b7f9b1b338dbdeee9c0d4ad72e13de94b9f22c")

    def config_options(self):
        if self.settings.os == "Windows":
            del self.options.fPIC

    def layout(self):
        cmake_layout(self)

    def generate(self):
        deps = CMakeDeps(self)
        deps.generate()
        tc = CMakeToolchain(self)
        tc.generate()

    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

    def package(self):
        cmake = CMake(self)
        cmake.install()

    def package_info(self):
        if self.options.shared:
            self.cpp_info.libs = ["HelloWorld"]
        else:
            self.cpp_info.libs = ["HelloWorld_Static"]
