homebrew-core/Formula/itk.rb

105 lines
3.3 KiB
Ruby

class Itk < Formula
desc "Insight Toolkit is a toolkit for performing registration and segmentation"
homepage "https://itk.org"
url "https://github.com/InsightSoftwareConsortium/ITK/releases/download/v5.2.0/InsightToolkit-5.2.0.tar.gz"
sha256 "12c9cf543cbdd929330322f0a704ba6925a13d36d01fc721a74d131c0b82796e"
license "Apache-2.0"
head "https://github.com/InsightSoftwareConsortium/ITK.git"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 arm64_big_sur: "9f3de242d8a5c5853eefc9182e95a61df874976477d628b67e89cebc05171518"
sha256 big_sur: "1a49221acac07be2ed23f90e952a06e11755d08bd9cc9c5541dfaf90dca21929"
sha256 catalina: "1132b2538895f3cceb81084deef22a067b324617fb3ba035ac559d8b46780810"
sha256 mojave: "a786438d13ae1caebf645a45f85956bca04863645cb8bf28c88df26b0dfd9e07"
end
depends_on "cmake" => :build
depends_on "fftw"
depends_on "gdcm"
depends_on "hdf5"
depends_on "jpeg"
depends_on "libpng"
depends_on "libtiff"
depends_on "vtk@8.2" # needed for gdcm
on_linux do
depends_on "alsa-lib"
depends_on "unixodbc"
end
def install
args = std_cmake_args + %W[
-DBUILD_SHARED_LIBS=ON
-DBUILD_TESTING=OFF
-DCMAKE_INSTALL_RPATH:STRING=#{lib}
-DCMAKE_INSTALL_NAME_DIR:STRING=#{lib}
-DITK_USE_64BITS_IDS=ON
-DITK_USE_STRICT_CONCEPT_CHECKING=ON
-DITK_USE_SYSTEM_ZLIB=ON
-DITK_USE_SYSTEM_EXPAT=ON
-DModule_SCIFIO=ON
-DITKV3_COMPATIBILITY:BOOL=OFF
-DITK_USE_SYSTEM_FFTW=ON
-DITK_USE_FFTWF=ON
-DITK_USE_FFTWD=ON
-DITK_USE_SYSTEM_HDF5=ON
-DITK_USE_SYSTEM_JPEG=ON
-DITK_USE_SYSTEM_PNG=ON
-DITK_USE_SYSTEM_TIFF=ON
-DITK_USE_SYSTEM_GDCM=ON
-DITK_LEGACY_REMOVE=ON
-DModule_ITKReview=ON
-DModule_ITKVtkGlue=ON
-DITK_USE_GPU=ON
]
# Avoid references to the Homebrew shims directory
inreplace "Modules/Core/Common/src/CMakeLists.txt" do |s|
s.gsub!(/MAKE_MAP_ENTRY\(\s*\\"CMAKE_C_COMPILER\\",
\s*\\"\${CMAKE_C_COMPILER}\\".*\);/x,
"MAKE_MAP_ENTRY(\\\"CMAKE_C_COMPILER\\\", " \
"\\\"#{ENV.cc}\\\", \\\"The C compiler.\\\");")
s.gsub!(/MAKE_MAP_ENTRY\(\s*\\"CMAKE_CXX_COMPILER\\",
\s*\\"\${CMAKE_CXX_COMPILER}\\".*\);/x,
"MAKE_MAP_ENTRY(\\\"CMAKE_CXX_COMPILER\\\", " \
"\\\"#{ENV.cxx}\\\", \\\"The CXX compiler.\\\");")
end
mkdir "build" do
system "cmake", "..", *args
system "make"
system "make", "install"
end
end
test do
(testpath/"test.cxx").write <<-EOS
#include "itkImage.h"
int main(int argc, char* argv[])
{
typedef itk::Image<unsigned short, 3> ImageType;
ImageType::Pointer image = ImageType::New();
image->Update();
return EXIT_SUCCESS;
}
EOS
v = version.major_minor
# Build step
system ENV.cxx, "-std=c++11", "-isystem", "#{include}/ITK-#{v}", "-o", "test.cxx.o", "-c", "test.cxx"
# Linking step
system ENV.cxx, "-std=c++11", "test.cxx.o", "-o", "test",
"#{lib}/libITKCommon-#{v}.1.dylib",
"#{lib}/libITKVNLInstantiation-#{v}.1.dylib",
"#{lib}/libitkvnl_algo-#{v}.1.dylib",
"#{lib}/libitkvnl-#{v}.1.dylib"
system "./test"
end
end