Cannot open include file: 'magic_enum.hpp': No such file or directory

Viewed 514

I want to write a test program for this lib https://github.com/Neargye/magic_enum with Conan and CMake.

This is my conanfile.py to create the pacakge

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

And this is consumer

[requires]
magic_enum/0.7.2@jenkins/stable

[generators]
cmake

With this app I am getting an error:

#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})
0 Answers
Related