diff --git a/recipes/lwlog/all/conandata.yml b/recipes/lwlog/all/conandata.yml new file mode 100644 index 0000000000000..e1e21351d048d --- /dev/null +++ b/recipes/lwlog/all/conandata.yml @@ -0,0 +1,5 @@ +sources: + "latest": + url: + - "https://github.com/ChristianPanov/lwlog/archive/refs/heads/master.zip" + sha256: "687ccccec729548526aecb5287df071f28b37aa78fb4923092a97f71a6869c31" diff --git a/recipes/lwlog/all/conanfile.py b/recipes/lwlog/all/conanfile.py new file mode 100644 index 0000000000000..2b508c0836caa --- /dev/null +++ b/recipes/lwlog/all/conanfile.py @@ -0,0 +1,55 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps + + +class lwlogRecipe(ConanFile): + name = "lwlog" + version = "latest" + package_type = "library" + + # Optional metadata + license = "MIT" + author = "Christian Panov" + url = "https://github.com/ChristianPanov/lwlog" + description = "Very fast synchronous and asynchronous C++17 logging library" + topics = ("library", "cpp", "asynchronous", "high-performance", "logger", "logging", "metaprogramming", "logging-library", "cpp17", "low-latency", "logger-middleware", "logging-framework", "cpp17-library", "lwlog") + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + options = {"fPIC": [True, False]} + default_options = {"fPIC": True} + + # Sources are located in the same place as this recipe, copy them to the recipe + exports_sources = "CMakeLists.txt", "Config.cmake.in", "lwlog/src/*", "Sandbox/*" + + def config_options(self): + if self.settings.os == "Windows": + self.options.rm_safe("fPIC") + + def configure(self): + if self.options.shared: + self.options.rm_safe("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): + self.cpp_info.libs = ["lwlog_lib"] + self.cpp_info.set_property("cmake_file_name", "lwlog") + self.cpp_info.set_property("cmake_target_name", "lwlog::lwlog_lib") + self.cpp_info.includedirs = ["include/src"] \ No newline at end of file diff --git a/recipes/lwlog/all/test_package/CMakeLists.txt b/recipes/lwlog/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a232aa28a29fd --- /dev/null +++ b/recipes/lwlog/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.15) +project(PackageTest CXX) + +find_package(lwlog CONFIG REQUIRED) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(example test_package.cpp) +target_link_libraries(example lwlog::lwlog_lib) diff --git a/recipes/lwlog/all/test_package/conanfile.py b/recipes/lwlog/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b170b95435161 --- /dev/null +++ b/recipes/lwlog/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +import os + +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run + + +class lwlogTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def layout(self): + cmake_layout(self) + + def test(self): + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "example") + self.run(cmd, env="conanrun") diff --git a/recipes/lwlog/all/test_package/test_package.cpp b/recipes/lwlog/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..94f1bbb4f58ce --- /dev/null +++ b/recipes/lwlog/all/test_package/test_package.cpp @@ -0,0 +1,27 @@ +#include "lwlog.h" + +int main() +{ + using logger_config = lwlog::configuration< + lwlog::disable_local_time, + lwlog::disable_thread_id, + lwlog::disable_process_id, + lwlog::disable_topics>; + + auto console = std::make_shared< + lwlog::logger< + logger_config, + lwlog::asynchronous_policy< + lwlog::default_async_queue_size, + lwlog::default_overflow_policy>, + lwlog::immediate_flush_policy, + lwlog::single_threaded_policy, + lwlog::sinks::stdout_sink>>("CONSOLE"); + + console->set_level_filter(lwlog::level::info | lwlog::level::debug | lwlog::level::critical); + console->set_pattern(".red([%T] [%n]) .dark_green([%l]): .cyan(%v) TEXT"); + + console->critical("First critical message"); + + return 0; +} diff --git a/recipes/lwlog/config.yml b/recipes/lwlog/config.yml new file mode 100644 index 0000000000000..6285e212d9b09 --- /dev/null +++ b/recipes/lwlog/config.yml @@ -0,0 +1,3 @@ +versions: + "latest": + folder: all