无法打开包含文件:'magic_enum.hpp':没有这样的文件或目录

问题描述

我想用 Conan 和 CMake 为这个库 https://github.com/Neargye/magic_enum 编写一个测试程序。

这是我用来创建包的 conanfile.py

from conans import ConanFile,CMake,tools


class MagicEnumConan(ConanFile):
    name = "magic_enum"
    version = "0.7.2"
    # No settings/options are necessary,this is header only
    #exports_sources = "include/*"
    no_copy_source = True

    def source(self):
        self.run("git clone https://github.com/Neargye/magic_enum.git")

    def package(self):
        self.copy("*.hpp",dst="include",src="include",keep_path=False)

    def package_id(self):
        self.info.header_only()

这是消费者

[requires]
magic_enum/0.7.2@jenkins/stable

[generators]
cmake

使用此应用程序时出现错误

#include <iostream>

#include <magic_enum.hpp>

// For example color enum.
enum class Color { RED = 2,BLUE = 4,GREEN = 8 };

int main()
{
    Color color = Color::RED;
    auto color_name = magic_enum::enum_name(color);
    // color_name -> "RED"
    
    std::cout << color_name << std::endl;
} 

D:\conan_test\consumer\main.cpp(3,10): Fatal error C1083: Cannot open include file: 'magic_enum.hpp': No such file or directory [D:\conan_test\consumer\build\magic_enum.vcxproj]

CMakeLists.txt

 cmake_minimum_required(VERSION 2.8.12)
 project(MagicEnum)

 add_deFinitions("-std=c++11")

 include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
 conan_basic_setup()

 add_executable(magic_enum main.cpp)
 target_link_libraries(magic_enum ${CONAN_LIBS})

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)