|
| 1 | +# SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 | +# SPDX-FileNotice: Part of the FreeCAD project. |
| 3 | + |
| 4 | +class NetgenAT622601 < Formula |
| 5 | + desc "C++ Library of NETGEN's tetrahedral mesh generator" |
| 6 | + homepage "https://github.com/ngsolve/netgen" |
| 7 | + url "https://github.com/ngsolve/netgen.git", |
| 8 | + tag: "v6.2.2601" |
| 9 | + license "LGPL-2.1-only" |
| 10 | + head "https://github.com/ngsolve/netgen.git", branch: "master" |
| 11 | + |
| 12 | + keg_only :versioned_formula |
| 13 | + |
| 14 | + depends_on "cmake" => :build |
| 15 | + depends_on "llvm" => [:build, :test] |
| 16 | + depends_on "ninja" => :build |
| 17 | + depends_on "opencascade" |
| 18 | + depends_on "pybind11" |
| 19 | + depends_on "python@3.13" |
| 20 | + depends_on "zlib-ng-compat" |
| 21 | + |
| 22 | + def install |
| 23 | + ENV["CC"] = Formula["llvm"].opt_bin/"clang" |
| 24 | + ENV["CXX"] = Formula["llvm"].opt_bin/"clang++" |
| 25 | + |
| 26 | + python3 = Formula["python@3.13"].opt_bin/"python3.13" |
| 27 | + |
| 28 | + ENV["PYTHON"] = python3.to_s |
| 29 | + |
| 30 | + # Get the Python includes directory without duplicates |
| 31 | + py_inc_output = `#{python3}-config --includes` |
| 32 | + py_inc_dirs = py_inc_output.scan(/-I([^\s]+)/).flatten.uniq |
| 33 | + py_inc_dir = py_inc_dirs.join(" ") |
| 34 | + |
| 35 | + puts "----------------------------------------------------" |
| 36 | + puts "PYTHON=#{ENV["PYTHON"]}" |
| 37 | + puts "----------------------------------------------------" |
| 38 | + |
| 39 | + args = %W[ |
| 40 | + -DCMAKE_INSTALL_PREFIX=#{prefix} |
| 41 | + -DUSE_PYTHON=ON |
| 42 | + -DPython3_EXECUTABLE=#{python3} |
| 43 | + -DPython3_INCLUDE_DIR=#{py_inc_dir} |
| 44 | + -DUSE_GUI=OFF |
| 45 | + -DUSE_OCC=ON |
| 46 | + -DUSE_SUPERBUILD=OFF |
| 47 | + -DBUILD_FOR_CONDA=OFF |
| 48 | + -G Ninja |
| 49 | + -L |
| 50 | + ] |
| 51 | + |
| 52 | + system "cmake", "-S", ".", "-B", "build", *args |
| 53 | + system "cmake", "--build", "build" |
| 54 | + system "cmake", "--install", "build" |
| 55 | + end |
| 56 | + |
| 57 | + def caveats |
| 58 | + <<~EOS |
| 59 | + this is a versioned formula so it is NOT linked in HOMBREW_PREFIX by default |
| 60 | + running brew test netgen currently fails with gcc if built with llvm |
| 61 | + EOS |
| 62 | + end |
| 63 | + |
| 64 | + test do |
| 65 | + ENV["CC"] = Formula["llvm"].opt_bin/"clang" |
| 66 | + ENV["CXX"] = Formula["llvm"].opt_bin/"clang++" |
| 67 | + |
| 68 | + # ng_inc = Formula["netgen@6.2.2601"].opt_include |
| 69 | + |
| 70 | + # include_flag = if (include/"include/meshing/meshing.hpp").exist? |
| 71 | + # "-I#{include}/include" |
| 72 | + # else |
| 73 | + # "-I#{include}" |
| 74 | + # end |
| 75 | + |
| 76 | + ng_include = if OS.mac? |
| 77 | + prefix/"Contents/Resources/include/include" |
| 78 | + else |
| 79 | + include/"include" |
| 80 | + end |
| 81 | + |
| 82 | + (testpath/"test.cpp").write <<~EOS |
| 83 | + #include <meshing/meshing.hpp> |
| 84 | + int main() { return 0; } |
| 85 | + EOS |
| 86 | + |
| 87 | + system ENV.cxx, "test.cpp", "-I#{ng_include}", "-L#{lib}", "-lnglib", "-o", "test" |
| 88 | + system "./test" |
| 89 | + end |
| 90 | +end |
0 commit comments