Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wise_enum: modernize #9156

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions recipes/wise_enum/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from conans import ConanFile, tools
from conans.errors import ConanInvalidConfiguration
import os
import sys

required_conan_version = ">=1.33.0"
required_conan_version = ">=1.43.0"


class WiseEnumConan(ConanFile):
name = "wise_enum"
description = "Header-only C++11/14/17 library provides static reflection for enums, work with any enum type without any boilerplate code."
description = (
"Header-only C++11/14/17 library provides static reflection for enums, "
"work with any enum type without any boilerplate code."
)
topics = (
"cplusplus",
"enum-to-string",
Expand All @@ -20,17 +22,17 @@ class WiseEnumConan(ConanFile):
homepage = "https://github.com/quicknir/wise_enum"
url = "https://github.com/conan-io/conan-center-index"
license = "BSL-1.0"
settings = "compiler"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
def _source_subfolder(self):
return "source_subfolder"

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, "11")

compiler = str(self.settings.compiler)
compiler_version = tools.Version(self.settings.compiler.version)

Expand All @@ -47,23 +49,28 @@ def validate(self):
raise ConanInvalidConfiguration(
"{} requires {} compiler {} or newer [is: {}]".format(self.name, compiler, minimal_version[compiler], compiler_version)
)


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

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def package(self):
self.copy("*.h", dst="include", src=self._source_subfolder)
self.copy("LICENSE", dst="licenses" , src=self._source_subfolder)

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "WiseEnum")
self.cpp_info.set_property("cmake_target_name", "WiseEnum::wise_enum")
self.cpp_info.set_property("pkg_config_name", "WiseEnum")

# TODO: to remove in conan v2 once cmake_find_package* generators removed
self.cpp_info.names["cmake_find_package"] = "WiseEnum"
self.cpp_info.names["cmake_find_package_multi"] = "WiseEnum"
self.cpp_info.names["pkg_config"] = "WiseEnum"
self.cpp_info.components["_wise_enum"].names["cmake_find_package"] = "wise_enum"
self.cpp_info.components["_wise_enum"].names["cmake_find_package_multi"] = "wise_enum"
self.cpp_info.components["_wise_enum"].names["pkg_config"] = "WiseEnum"
self.cpp_info.components["_wise_enum"].set_property("cmake_target_name", "WiseEnum::wise_enum")
self.cpp_info.components["_wise_enum"].set_property("pkg_config_name", "WiseEnum")