Skip to content

Instantly share code, notes, and snippets.

@tfmoraes
Created Apr 10, 2019
Embed
What would you like to do?
class Gdcm < Formula
desc "Grassroots DICOM library and utilities for medical files"
homepage "https://sourceforge.net/projects/gdcm/"
url "https://downloads.sourceforge.net/project/gdcm/gdcm%202.x/GDCM%202.8.9/gdcm-2.8.9.tar.gz"
sha256 "a2da88b7b3cbf9e76a9df3e89d06d057cca9ce54fc62fb059e04f47bf056b727"
bottle do
sha256 "9f3d3a1de707e4184bc62fa7070fccb39c9fd1864966e49dc58e93c0616ec012" => :mojave
sha256 "ad87ce2f85f16278131b692b12c33cbf1f02af7263c04a9b3dc1cb8188bcdf53" => :high_sierra
sha256 "ba985660d7000a4f8b054a63269c60cab9c542e46e81864d8ef8621c2a246cbf" => :sierra
sha256 "66d1542a14b6c6e75946853944662d4a934101ceb9c865a9c1da527884133bd6" => :el_capitan
end
patch do
url "https://gist.githubusercontent.com/tfmoraes/eacb51381e2595b9dfea74d9c901cbd7/raw/b9a739e0337ab5a9577965869989de5213e3a5a7/vtkgdcm_compile.diff"
sha256 "ad9c8a2217013d516658f1edd3012b2203fd87f1ba541426284c66aa4d5c1533"
end
depends_on "cmake" => :build
depends_on "pkg-config" => :build
depends_on "swig" => :build
depends_on "openjpeg"
depends_on "openssl"
depends_on "python"
depends_on "vtk"
def install
ENV.cxx11
xy = Language::Python.major_minor_version "python3"
python_include = Utils.popen_read("python3 -c 'from distutils import sysconfig;print(sysconfig.get_python_inc(True))'").chomp
python_executable = Utils.popen_read("python3 -c 'import sys;print(sys.executable)'").chomp
args = std_cmake_args + %W[
-DGDCM_BUILD_APPLICATIONS=ON
-DGDCM_BUILD_SHARED_LIBS=ON
-DGDCM_BUILD_TESTING=OFF
-DGDCM_BUILD_EXAMPLES=OFF
-DGDCM_BUILD_DOCBOOK_MANPAGES=OFF
-DGDCM_USE_VTK=ON
-DGDCM_USE_SYSTEM_OPENJPEG=ON
-DGDCM_USE_SYSTEM_OPENSSL=ON
-DGDCM_WRAP_PYTHON=ON
-DPYTHON_EXECUTABLE=#{python_executable}
-DPYTHON_INCLUDE_DIR=#{python_include}
-DGDCM_INSTALL_PYTHONMODULE_DIR=#{lib}/python#{xy}/site-packages
-DCMAKE_INSTALL_RPATH=#{lib}
-DGDCM_NO_PYTHON_LIBS_LINKING=ON
]
mkdir "build" do
ENV.append "LDFLAGS", "-undefined dynamic_lookup"
system "cmake", "..", *args
system "make", "install"
end
end
test do
(testpath/"test.cxx").write <<~EOS
#include "gdcmReader.h"
int main(int, char *[])
{
gdcm::Reader reader;
reader.SetFileName("file.dcm");
}
EOS
system ENV.cxx, "-isystem", "#{include}/gdcm-2.8", "-o", "test.cxx.o", "-c", "test.cxx"
system ENV.cxx, "test.cxx.o", "-o", "test", "-L#{lib}", "-lgdcmDSED"
system "./test"
system "python3", "-c", "import gdcm"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment