diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..6af42b9 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +from conans import ConanFile + +class MagicEnumConan(ConanFile): + name = 'magic_enum' + version = '0.6.0' + description = 'Header-only C++17 library provides static reflection for enums, work with any enum type without any macro or boilerplate code.' + topics = ( + 'conan', + 'cplusplus', + 'enum-to-string', + 'string-to-enum' + 'serialization', + 'reflection', + 'header-only', + 'compile-time' + ) + url = 'https://github.com/Neargye/magic_enum' + homepage = 'https://github.com/Neargye/magic_enum' + author = 'Daniil Goncharov ' + license = 'MIT' + exports_sources = ["include/*", "LICENCE"] + exports = ["LICENSE"] + no_copy_source = True + + def package(self): + self.copy("include/*") + self.copy("LICENSE", dst="licenses") + + def package_id(self): + self.info.header_only() diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt new file mode 100644 index 0000000..5c2fbc4 --- /dev/null +++ b/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_executable(test_package test_package.cpp) +target_link_libraries(test_package PRIVATE CONAN_PKG::magic_enum) +target_compile_features(test_package PRIVATE cxx_std_17) diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 0000000..3afe456 --- /dev/null +++ b/test_package/conanfile.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from conans import ConanFile, CMake, tools +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/test_package/test_package.cpp b/test_package/test_package.cpp new file mode 100644 index 0000000..f0c1dee --- /dev/null +++ b/test_package/test_package.cpp @@ -0,0 +1,15 @@ +#include + +#include + +enum class Color : int { RED = -10, BLUE = 0, GREEN = 10 }; + +int main() { + auto res1 = magic_enum::enum_name(Color::RED); + auto res2 = magic_enum::enum_cast("BLUE"); + auto res3 = magic_enum::enum_cast(10); + + bool success = (res1 == "RED") && (res2.value() == Color::BLUE) && (res3.value() == Color::GREEN); + + return success ? EXIT_SUCCESS : EXIT_FAILURE; +}