homebrew-core/Formula/magic_enum.rb

40 lines
1.1 KiB
Ruby

class MagicEnum < Formula
desc "Static reflection for enums (to string, from string, iteration) for modern C++"
homepage "https://github.com/Neargye/magic_enum"
url "https://github.com/Neargye/magic_enum/archive/v0.7.3.tar.gz"
sha256 "b8d0cd848546fee136dc1fa4bb021a1e4dc8fe98e44d8c119faa3ef387636bf7"
license "MIT"
bottle do
sha256 cellar: :any_skip_relocation, all: "1f8a29b1340f383c2f4c8fc9d5e81b0415a35ee62fe95bfa103a50e95b987e04"
end
depends_on "cmake" => :build
def install
system "cmake", ".", *std_cmake_args
system "make", "install"
system "./test/test-cpp17"
system "./test/test-cpp17"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <iostream>
#include <magic_enum.hpp>
enum class Color : int { RED = -10, BLUE = 0, GREEN = 10 };
int main() {
Color c1 = Color::RED;
auto c1_name = magic_enum::enum_name(c1);
std::cout << c1_name << std::endl;
return 0;
}
EOS
system ENV.cxx, "test.cpp", "-I#{include}", "-Wall", "-Wextra", "-pedantic-errors", "-Werror", "-std=c++17"
system "./a.out"
end
end