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

add conan

This commit is contained in:
neargye 2019-08-24 12:23:22 +05:00
parent ef36e2e218
commit 409e9e1afd
4 changed files with 74 additions and 0 deletions

View file

@ -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)

18
test_package/conanfile.py Normal file
View file

@ -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)

View file

@ -0,0 +1,15 @@
#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;
}