class Libosmium < Formula
desc "Fast and flexible C++ library for working with OpenStreetMap data"
homepage "https://osmcode.org/libosmium/"
url "https://github.com/osmcode/libosmium/archive/v2.15.4.tar.gz"
sha256 "402247f7764bc20c061fa7d9fad15fc85459b7ce4f420274de78c94d05ddf260"
bottle do
cellar :any_skip_relocation
sha256 "5f28c305b9a1f40e5967de56a4a4dd02822e3edf4c08f78f30516e1c163244ce" => :catalina
sha256 "5f28c305b9a1f40e5967de56a4a4dd02822e3edf4c08f78f30516e1c163244ce" => :mojave
sha256 "5f28c305b9a1f40e5967de56a4a4dd02822e3edf4c08f78f30516e1c163244ce" => :high_sierra
end
depends_on "boost" => :build
depends_on "cmake" => :build
resource "protozero" do
url "https://github.com/mapbox/protozero/archive/v1.6.8.tar.gz"
sha256 "019a0f3789ad29d7e717cf2e0a7475b36dc180508867fb47e8c519885b431706"
end
def install
resource("protozero").stage { libexec.install "include" }
system "cmake", ".", "-DINSTALL_GDALCPP=ON",
"-DINSTALL_UTFCPP=ON",
"-DPROTOZERO_INCLUDE_DIR=#{libexec}/include",
*std_cmake_args
system "make", "install"
end
test do
(testpath/"test.osm").write <<~EOS
EOS
(testpath/"test.cpp").write <<~EOS
#include
#include
#include
int main(int argc, char* argv[]) {
osmium::io::File input_file{argv[1]};
osmium::io::Reader reader{input_file};
while (osmium::memory::Buffer buffer = reader.read()) {}
reader.close();
}
EOS
system ENV.cxx, "-std=c++11", "-stdlib=libc++", "-lexpat", "-o", "libosmium_read", "test.cpp"
system "./libosmium_read", "test.osm"
end
end