1
0
Fork 0
mirror of https://github.com/Neargye/magic_enum.git synced 2026-01-09 23:34:23 +00:00

now in conan-center (#41)

This commit is contained in:
Daniil Goncharov 2020-06-27 11:22:29 +05:00 committed by GitHub
parent 2b0dcc9cfd
commit dbd1c76400
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 2 additions and 97 deletions

View file

@ -10,7 +10,7 @@
```
[![Github releases](https://img.shields.io/github/release/Neargye/magic_enum.svg)](https://github.com/Neargye/magic_enum/releases)
[![Conan package](https://img.shields.io/badge/Conan-package-blueviolet)](https://bintray.com/neargye/conan-packages/magic_enum:neargye)
[![Conan package](https://img.shields.io/badge/Conan-package-blueviolet)](https://conan.io/center/magic_enum/0.6.6)
[![Vcpkg package](https://img.shields.io/badge/Vcpkg-package-blueviolet)](https://github.com/microsoft/vcpkg/tree/master/ports/magic-enum)
[![License](https://img.shields.io/github/license/Neargye/magic_enum.svg)](LICENSE)
[![Build status](https://travis-ci.org/Neargye/magic_enum.svg?branch=master)](https://travis-ci.org/Neargye/magic_enum)
@ -205,7 +205,7 @@ You should add the required file [magic_enum.hpp](include/magic_enum.hpp).
If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can use the [magic_enum package](https://github.com/microsoft/vcpkg/tree/master/ports/magic-enum).
If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `magic_enum/x.y.z@neargye/stable` to your conan's requires, where `x.y.z` is the release version you want to use.
If you are using [Conan](https://www.conan.io/) to manage your dependencies, merely add `magic_enum/x.y.z` to your conan's requires, where `x.y.z` is the release version you want to use.
Alternatively, you can use something like [CPM](https://github.com/TheLartians/CPM) which is based on CMake's `Fetch_Content` module.

View file

@ -1,52 +0,0 @@
# -*- coding: utf-8 -*-
from conans import ConanFile, tools
from conans.errors import ConanInvalidConfiguration
class MagicEnumConan(ConanFile):
name = "magic_enum"
version = "0.6.6"
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 <neargye@gmail.com>"
license = "MIT"
exports_sources = ["include/*", "LICENCE"]
exports = ["LICENSE"]
settings = "compiler"
no_copy_source = True
@property
def supported_compiler(self):
compiler = str(self.settings.compiler)
version = tools.Version(self.settings.compiler.version)
if compiler == "Visual Studio" and version >= "15":
return True
if compiler == "gcc" and version >= "9":
return True
if compiler == "clang" and version >= "5":
return True
if compiler == "apple-clang" and version >= "10":
return True
return False
def configure(self):
if not self.supported_compiler:
raise ConanInvalidConfiguration("magic_enum: Unsupported compiler (https://github.com/Neargye/magic_enum#compiler-compatibility).")
def package(self):
self.copy("include/*")
self.copy("LICENSE", dst="licenses")
def package_id(self):
self.info.header_only()

View file

@ -1,10 +0,0 @@
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)
set_target_properties(test_package PROPERTIES CXX_EXTENSIONS OFF)
target_compile_features(test_package PRIVATE cxx_std_17)

View file

@ -1,18 +0,0 @@
# -*- 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)

View file

@ -1,15 +0,0 @@
#include <magic_enum.hpp>
#include <cstdlib>
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<Color>("BLUE");
auto res3 = magic_enum::enum_cast<Color>(10);
bool success = (res1 == "RED") && (res2.value() == Color::BLUE) && (res3.value() == Color::GREEN);
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}