158 lines
5.8 KiB
Ruby
158 lines
5.8 KiB
Ruby
class Vtk < Formula
|
|
desc "Toolkit for 3D computer graphics, image processing, and visualization"
|
|
homepage "https://www.vtk.org/"
|
|
url "https://www.vtk.org/files/release/9.2/VTK-9.2.4.tar.gz"
|
|
sha256 "9ed0d55c923778469357412d3f6bdd4841a31c30be997a53a7b0632d815cbc9c"
|
|
license "BSD-3-Clause"
|
|
head "https://gitlab.kitware.com/vtk/vtk.git", branch: "master"
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_ventura: "01b2e5aa9511990a7e811c5504805c565d9d0523936b48fd088395adaa06c401"
|
|
sha256 cellar: :any, arm64_monterey: "817802d42b2b39b03190edbdffccce561e18d8e91d4b611d3b4eacad46354dc9"
|
|
sha256 cellar: :any, arm64_big_sur: "828333bb68bceab7dfb27bfd64d0c7348c20ae6b50994774331513c14c87f47b"
|
|
sha256 cellar: :any, ventura: "9320bc8e51fd0e1245930af8ef854024e57e54f92bd2b6aeb29af1e5f4fc7cf8"
|
|
sha256 cellar: :any, monterey: "53af9bd5b425a87cb7e2ff88ad607c5e96a158259e1c074d16ca12c79218918d"
|
|
sha256 cellar: :any, big_sur: "60d98948a79834a67b3395282b341f9ac92807639ab532725f872d7fc0662968"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "a5eac0cf0b55c6984509e96d6bd0f6f9163e13aac823e835fd38614ead4d2d81"
|
|
end
|
|
|
|
depends_on "cmake" => [:build, :test]
|
|
depends_on "boost"
|
|
depends_on "double-conversion"
|
|
depends_on "eigen"
|
|
depends_on "fontconfig"
|
|
depends_on "gl2ps"
|
|
depends_on "glew"
|
|
depends_on "hdf5"
|
|
depends_on "jpeg-turbo"
|
|
depends_on "jsoncpp"
|
|
depends_on "libogg"
|
|
depends_on "libpng"
|
|
depends_on "libtiff"
|
|
depends_on "lz4"
|
|
depends_on "netcdf"
|
|
depends_on "pugixml"
|
|
depends_on "pyqt@5"
|
|
depends_on "python@3.11"
|
|
depends_on "qt@5"
|
|
depends_on "sqlite"
|
|
depends_on "theora"
|
|
depends_on "utf8cpp"
|
|
depends_on "xz"
|
|
|
|
uses_from_macos "expat"
|
|
uses_from_macos "libxml2"
|
|
uses_from_macos "tcl-tk"
|
|
uses_from_macos "zlib"
|
|
|
|
on_macos do
|
|
on_arm do
|
|
if DevelopmentTools.clang_build_version == 1316
|
|
depends_on "llvm" => :build
|
|
|
|
# clang: error: unable to execute command: Segmentation fault: 11
|
|
# clang: error: clang frontend command failed due to signal (use -v to see invocation)
|
|
# Apple clang version 13.1.6 (clang-1316.0.21.2)
|
|
fails_with :clang
|
|
end
|
|
end
|
|
end
|
|
|
|
on_linux do
|
|
depends_on "libaec"
|
|
depends_on "mesa-glu"
|
|
end
|
|
|
|
fails_with gcc: "5"
|
|
|
|
def install
|
|
ENV.llvm_clang if DevelopmentTools.clang_build_version == 1316 && Hardware::CPU.arm?
|
|
|
|
args = %W[
|
|
-DBUILD_SHARED_LIBS:BOOL=ON
|
|
-DCMAKE_INSTALL_NAME_DIR:STRING=#{opt_lib}
|
|
-DCMAKE_INSTALL_RPATH:STRING=#{rpath}
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_ICU:BOOL=ON
|
|
-DVTK_WRAP_PYTHON:BOOL=ON
|
|
-DVTK_PYTHON_VERSION:STRING=3
|
|
-DVTK_LEGACY_REMOVE:BOOL=ON
|
|
-DVTK_MODULE_ENABLE_VTK_InfovisBoost:STRING=YES
|
|
-DVTK_MODULE_ENABLE_VTK_InfovisBoostGraphAlgorithms:STRING=YES
|
|
-DVTK_MODULE_ENABLE_VTK_RenderingFreeTypeFontConfig:STRING=YES
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_doubleconversion:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_eigen:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_expat:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_gl2ps:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_glew:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_hdf5:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_jpeg:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_jsoncpp:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_libxml2:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_lz4:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_lzma:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_netcdf:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_ogg:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_png:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_pugixml:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_sqlite:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_theora:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_tiff:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_utf8:BOOL=ON
|
|
-DVTK_MODULE_USE_EXTERNAL_VTK_zlib:BOOL=ON
|
|
-DPython3_EXECUTABLE:FILEPATH=#{which("python3.11")}
|
|
-DVTK_GROUP_ENABLE_Qt:STRING=YES
|
|
-DVTK_QT_VERSION:STRING=5
|
|
]
|
|
|
|
# https://github.com/Homebrew/linuxbrew-core/pull/21654#issuecomment-738549701
|
|
args << "-DOpenGL_GL_PREFERENCE=LEGACY"
|
|
|
|
args << "-DVTK_USE_COCOA:BOOL=ON" if OS.mac?
|
|
|
|
system "cmake", "-S", ".", "-B", "build", *std_cmake_args, *args
|
|
system "cmake", "--build", "build"
|
|
system "cmake", "--install", "build"
|
|
end
|
|
|
|
test do
|
|
# Force use of Apple Clang on macOS that needs LLVM to build
|
|
ENV.clang if DevelopmentTools.clang_build_version == 1316 && Hardware::CPU.arm?
|
|
|
|
vtk_dir = lib/"cmake/vtk-#{version.major_minor}"
|
|
vtk_cmake_module = vtk_dir/"VTK-vtk-module-find-packages.cmake"
|
|
assert_match Formula["boost"].version.to_s, vtk_cmake_module.read, "VTK needs to be rebuilt against Boost!"
|
|
|
|
(testpath/"CMakeLists.txt").write <<~EOS
|
|
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
|
project(Distance2BetweenPoints LANGUAGES CXX)
|
|
find_package(VTK REQUIRED COMPONENTS vtkCommonCore CONFIG)
|
|
add_executable(Distance2BetweenPoints Distance2BetweenPoints.cxx)
|
|
target_link_libraries(Distance2BetweenPoints PRIVATE ${VTK_LIBRARIES})
|
|
EOS
|
|
|
|
(testpath/"Distance2BetweenPoints.cxx").write <<~EOS
|
|
#include <cassert>
|
|
#include <vtkMath.h>
|
|
int main() {
|
|
double p0[3] = {0.0, 0.0, 0.0};
|
|
double p1[3] = {1.0, 1.0, 1.0};
|
|
assert(vtkMath::Distance2BetweenPoints(p0, p1) == 3.0);
|
|
return 0;
|
|
}
|
|
EOS
|
|
|
|
system "cmake", ".", "-DCMAKE_BUILD_TYPE=Debug", "-DCMAKE_VERBOSE_MAKEFILE=ON", "-DVTK_DIR=#{vtk_dir}"
|
|
system "make"
|
|
system "./Distance2BetweenPoints"
|
|
|
|
(testpath/"Distance2BetweenPoints.py").write <<~EOS
|
|
import vtk
|
|
p0 = (0, 0, 0)
|
|
p1 = (1, 1, 1)
|
|
assert vtk.vtkMath.Distance2BetweenPoints(p0, p1) == 3
|
|
EOS
|
|
|
|
system bin/"vtkpython", "Distance2BetweenPoints.py"
|
|
end
|
|
end
|