Skip to content

Commit

Permalink
libsbml 5.20.2 (new formula) (#1672)
Browse files Browse the repository at this point in the history
  • Loading branch information
Waschina committed May 6, 2024
1 parent 4ee281f commit 34f9b43
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions Formula/libsbml.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
class Libsbml < Formula
desc "Library for handling SBML (Systems Biology Markup Language)"
homepage "https://sbml.org/software/libsbml"
url "https://github.com/sbmlteam/libsbml/archive/refs/tags/v5.20.2.tar.gz"
sha256 "a196cab964b0b41164d4118ef20523696510bbfd264a029df00091305a1af540"
license "LGPL-2.1-only"

depends_on "check" => :build
depends_on "cmake" => :build
depends_on "pkg-config" => :build

uses_from_macos "bzip2"
uses_from_macos "libxml2"

def install
# avoid an error "invalid conversion from ‘const xmlError*’"
ENV.append_to_cflags "-fpermissive" if OS.linux?
args = %w[
-DWITH_SWIG=OFF
-DWITH_ZLIB=OFF
-DWITH_BZIP2=ON
-DENABLE_COMP=ON
-DENABLE_FBC=ON
-DENABLE_GROUPS=ON
-DENABLE_L3V2EXTENDEDMATH=ON
-DENABLE_LAYOUT=ON
-DENABLE_MULTI=ON
-DENABLE_QUAL=ON
-DENABLE_RENDER=ON
]
args << "-DLIBSBML_DEPENDENCY_DIR=#{HOMEBREW_PREFIX}"
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end

test do
(testpath/"test.cpp").write <<~EOS
#include <sbml/SBMLTypes.h>
#include <sbml/packages/fbc/common/FbcExtensionTypes.h>
#include <sbml/packages/groups/common/GroupsExtensionTypes.h>
LIBSBML_CPP_NAMESPACE_USE
int main(int argc,char** argv)
{
SBMLNamespaces sbmlns(3,2);
sbmlns.addPkgNamespace("fbc",1);
sbmlns.addPkgNamespace("groups",1);
// create the document
SBMLDocument *document = new SBMLDocument(&sbmlns);
document->setPackageRequired("fbc", false);
document->setPackageRequired("groups", false);
// create the model
Model* model = document->createModel();
// basic test
model->setId("Homebrew_SBMLtest");
std::cout << model->getId() << std::endl;
return 0;
}
EOS
system ENV.cxx, "-std=c++17", "-L#{lib}", "-I#{include}", "test.cpp", "-o", "test", "-lsbml"
assert_equal "Homebrew_SBMLtest", shell_output("./test").strip
end
end

0 comments on commit 34f9b43

Please sign in to comment.