diff --git a/recipes/fenster/all/conandata.yml b/recipes/fenster/all/conandata.yml new file mode 100644 index 0000000000000..7580e925b5482 --- /dev/null +++ b/recipes/fenster/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.1.0": + url: "https://github.com/zserge/fenster/archive/refs/tags/v0.1.0.tar.gz" + sha256: "058bc7c7a28c66da5760bedfcc2a28b0f29f5cec640049b10e5ad2551b51d8de" diff --git a/recipes/fenster/all/conanfile.py b/recipes/fenster/all/conanfile.py new file mode 100644 index 0000000000000..7813a30b1a66f --- /dev/null +++ b/recipes/fenster/all/conanfile.py @@ -0,0 +1,74 @@ +import os + +from conan import ConanFile, conan_version +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout + +required_conan_version = ">=1.52.0" + + +class FensterConan(ConanFile): + name = "fenster" + description = "The most minimal cross-platform GUI library" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/zserge/fenster" + topics = ("gui", "audio", "minimal") + package_type = "header-library" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + options = { + "enable_graphics": [True, False], + "enable_audio": [True, False], + } + default_options = { + "enable_graphics": True, + "enable_audio": False, + } + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + if self.settings.os in ["Linux", "FreeBSD"]: + if self.options.enable_graphics: + self.requires("xorg/system") + if self.options.enable_audio: + self.requires("libalsa/1.2.12") + + def validate(self): + if conan_version.major == 1: + # linking against asound fails on C3I for v1 but not v2 + raise ConanInvalidConfiguration("This recipe is only compatible with Conan 2.0 or newer") + + def package_id(self): + self.info.clear() + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def package(self): + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", self.source_folder, os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + if self.options.enable_graphics: + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.requires.append("xorg::x11") + elif is_apple_os(self): + self.cpp_info.frameworks.append("Cocoa") + elif self.settings.os == "Windows": + self.cpp_info.system_libs.append("gdi32") + + if self.options.enable_audio: + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.requires.append("libalsa::libalsa") + elif is_apple_os(self): + self.cpp_info.frameworks.append("AudioToolbox") + elif self.settings.os == "Windows": + self.cpp_info.system_libs.append("winmm") diff --git a/recipes/fenster/all/test_package/CMakeLists.txt b/recipes/fenster/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3d4501868d357 --- /dev/null +++ b/recipes/fenster/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES C) + +find_package(fenster REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE fenster::fenster) diff --git a/recipes/fenster/all/test_package/conanfile.py b/recipes/fenster/all/test_package/conanfile.py new file mode 100644 index 0000000000000..bdc8c616b631b --- /dev/null +++ b/recipes/fenster/all/test_package/conanfile.py @@ -0,0 +1,29 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str, options={ + "enable_graphics": True, + "enable_audio": True, + }) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/fenster/all/test_package/test_package.c b/recipes/fenster/all/test_package/test_package.c new file mode 100644 index 0000000000000..aee2b04341b40 --- /dev/null +++ b/recipes/fenster/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include +#include + +#define W 320 +#define H 240 + +void dummy() { + uint32_t buf[W * H]; + struct fenster f = { .title = "hello", .width = W, .height = H, .buf = buf }; + fenster_open(&f); + fenster_close(&f); +} + +int main() { + return 0; +} diff --git a/recipes/fenster/config.yml b/recipes/fenster/config.yml new file mode 100644 index 0000000000000..6c11a439d0bc2 --- /dev/null +++ b/recipes/fenster/config.yml @@ -0,0 +1,3 @@ +versions: + "0.1.0": + folder: all