import os

import conan.tools.cmake
import conans.tools


class TestPackageConan(conans.ConanFile):
    settings = "os", "compiler", "build_type", "arch"
    generators = "cmake_find_package_multi"

    def generate(self):
        toolchain = conan.tools.cmake.CMakeToolchain(self)
        toolchain.generate()

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

    def test(self):
        if not conans.tools.cross_building(self.settings):
            self.run(os.path.join(os.getcwd(), "example"), run_environment=True)
