homebrew-core/Formula/gdcm.rb

96 lines
2.9 KiB
Ruby

class Gdcm < Formula
desc "Grassroots DICOM library and utilities for medical files"
homepage "https://sourceforge.net/projects/gdcm/"
url "https://github.com/malaterre/GDCM/archive/v3.0.10.tar.gz"
sha256 "a3fd3579ca0bb4a2a41ee18770e7303b22fd5460c3a2000e51ff0be6799e1d85"
license "BSD-3-Clause"
livecheck do
url :stable
strategy :github_latest
end
bottle do
sha256 arm64_big_sur: "5138339123c826603f3b95494e7311fc7488503bc16ee59cfbf60d90a1a562de"
sha256 big_sur: "7311b7b638ba5453aa9ac44521bd608f62c9d14fe8fb62106930268425fbf420"
sha256 catalina: "61776638059c775c87c91e11f4e6ccd8c9c30d7f56d6b2c8c3544ad88f703202"
sha256 mojave: "667f8feb062beb81b1d6d67404dfa6001aa1c731d39d3ed3627f5971f041647e"
sha256 x86_64_linux: "1ac6acce8386972afb7bfd2ac2c1ad25b44e6599d6d24ce99b4f695dfdd0488c"
end
depends_on "cmake" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "swig" => :build
depends_on "openjpeg"
depends_on "openssl@1.1"
depends_on "python@3.9"
depends_on "vtk@8.2"
uses_from_macos "expat"
uses_from_macos "zlib"
on_linux do
depends_on "gcc"
end
fails_with gcc: "5"
def install
ENV.cxx11
python3 = Formula["python@3.9"].opt_bin/"python3"
xy = Language::Python.major_minor_version python3
python_include =
Utils.safe_popen_read(python3, "-c", "from distutils import sysconfig;print(sysconfig.get_python_inc(True))")
.chomp
python_executable = Utils.safe_popen_read(python3, "-c", "import sys;print(sys.executable)").chomp
args = std_cmake_args + %W[
-GNinja
-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_EXPAT=ON
-DGDCM_USE_SYSTEM_ZLIB=ON
-DGDCM_USE_SYSTEM_UUID=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" if OS.mac?
system "cmake", "..", *args
system "ninja"
system "ninja", "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, "-std=c++11", "-isystem", "#{include}/gdcm-3.0", "-o", "test.cxx.o", "-c", "test.cxx"
system ENV.cxx, "-std=c++11", "test.cxx.o", "-o", "test", "-L#{lib}", "-lgdcmDSED"
system "./test"
system Formula["python@3.9"].opt_bin/"python3", "-c", "import gdcm"
end
end