homebrew-core/Formula/gdcm.rb

97 lines
3.1 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.19.tar.gz"
sha256 "52ee78a70aaee7e179d584c1b7116da607dbc59905c833dadbd85944c301769a"
license "BSD-3-Clause"
livecheck do
url :stable
strategy :github_latest
end
bottle do
sha256 arm64_monterey: "2430e5c92014ae3942652184009bb165fed03bdeedcc80f6c5af90fb323fbf82"
sha256 arm64_big_sur: "08b124c8900fd83521ff2656d5049abb60270ff300147ea03534ce9c85f448fc"
sha256 monterey: "c3e69799bfd8ad012a59cbfb6cc0c839d7ca13b3ebca34ab0e1b4f350956b29c"
sha256 big_sur: "a6d647c2c05d87568081b8d49d53917289a33333488b6a7b0e6c029a938191fb"
sha256 catalina: "b4d3deb87e071c27b54d0099361c6d9dfe814d9c928a3e563d74a68101d44a88"
sha256 x86_64_linux: "3ec557a5579c9e53ba831740abed26bd0402991f300a55c77529266655076e46"
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.10"
uses_from_macos "expat"
uses_from_macos "zlib"
on_linux do
depends_on "util-linux" # for libuuid
end
fails_with gcc: "5"
def python3
which("python3.10")
end
def install
python_include =
Utils.safe_popen_read(python3, "-c", "from distutils import sysconfig;print(sysconfig.get_python_inc(True))")
.chomp
prefix_site_packages = prefix/Language::Python.site_packages(python3)
args = [
"-DCMAKE_CXX_STANDARD=11",
"-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=OFF", # No VTK 9 support: https://sourceforge.net/p/gdcm/bugs/509/
"-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=#{python3}",
"-DPYTHON_INCLUDE_DIR=#{python_include}",
"-DGDCM_INSTALL_PYTHONMODULE_DIR=#{prefix_site_packages}",
"-DCMAKE_INSTALL_RPATH=#{rpath};#{rpath(source: prefix_site_packages)}",
"-DGDCM_NO_PYTHON_LIBS_LINKING=#{OS.mac?}",
]
if OS.mac?
%w[EXE SHARED MODULE].each do |type|
args << "-DCMAKE_#{type}_LINKER_FLAGS=-Wl,-undefined,dynamic_lookup -liconv"
end
end
system "cmake", "-S", ".", "-B", "build", "-G", "Ninja", *args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
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 python3, "-c", "import gdcm"
end
end