From db2d5d814ec5d09e3222bcd5f37b3994cd8be3ca Mon Sep 17 00:00:00 2001 From: abe-winter Date: Fri, 8 Dec 2023 16:27:15 -0500 Subject: [PATCH] add pinned suite-sparse, depend on pinned suite-sparse in ceres (#41) --- Formula/ceres-solver@2.1.rb | 8 ++++- Formula/suite-sparse@7.1.rb | 59 +++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 Formula/suite-sparse@7.1.rb diff --git a/Formula/ceres-solver@2.1.rb b/Formula/ceres-solver@2.1.rb index 1c83066..786f3e4 100644 --- a/Formula/ceres-solver@2.1.rb +++ b/Formula/ceres-solver@2.1.rb @@ -17,11 +17,17 @@ class CeresSolverAT21 < Formula depends_on "glog" depends_on "metis" depends_on "openblas" - depends_on "suite-sparse" + depends_on "suite-sparse@7.1" depends_on "tbb" fails_with gcc: "5" # C++17 + # Fix version detection for suite-sparse >= 6.0. Remove in next release. + patch do + url "https://github.com/ceres-solver/ceres-solver/commit/352b320ab1b5438a0838aea09cbbf07fa4ff5d71.patch?full_index=1" + sha256 "0289adbea4cb66ccff57eeb844dd6d6736c37649b6ff329fed73cf0e9461fb53" + end + def install system "cmake", "-S", ".", "-B", "homebrew-build", "-DBUILD_SHARED_LIBS=ON", diff --git a/Formula/suite-sparse@7.1.rb b/Formula/suite-sparse@7.1.rb new file mode 100644 index 0000000..208417a --- /dev/null +++ b/Formula/suite-sparse@7.1.rb @@ -0,0 +1,59 @@ +class SuiteSparseAT71 < Formula + desc "Suite of Sparse Matrix Software" + homepage "https://people.engr.tamu.edu/davis/suitesparse.html" + url "https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/refs/tags/v7.1.0.tar.gz" + sha256 "4cd3d161f9aa4f98ec5fa725ee5dc27bca960a3714a707a7d12b3d0abb504679" + license all_of: [ + "BSD-3-Clause", + "LGPL-2.1-or-later", + "GPL-2.0-or-later", + "Apache-2.0", + "GPL-3.0-only", + any_of: ["LGPL-3.0-or-later", "GPL-2.0-or-later"], + ] + + livecheck do + skip "intentionally held back" + end + + depends_on "cmake" => :build + depends_on "metis" + depends_on "openblas" + + uses_from_macos "m4" + + conflicts_with "mongoose", because: "suite-sparse vendors libmongoose.dylib" + + def install + # Force cmake to use our compiler shims + if OS.mac? + inreplace "GraphBLAS/cmake_modules/GraphBLAS_JIT_configure.cmake", + "GB_C_COMPILER \"${CMAKE_C_COMPILER}\"", "GB_C_COMPILER \"#{ENV.cc}\"" + end + + cmake_args = *std_cmake_args, "-DCMAKE_INSTALL_RPATH=#{rpath}" + args = [ + "INSTALL=#{prefix}", + "BLAS=-L#{Formula["openblas"].opt_lib} -lopenblas", + "LAPACK=$(BLAS)", + "MY_METIS_LIB=-L#{Formula["metis"].opt_lib} -lmetis", + "MY_METIS_INC=#{Formula["metis"].opt_include}", + "CMAKE_OPTIONS=#{cmake_args.join(" ")}", + "JOBS=#{ENV.make_jobs}", + ] + + # Parallelism is managed through the `JOBS` make variable and not with `-j`. + ENV.deparallelize + system "make", "library", *args + system "make", "install", *args + lib.install Dir["**/*.a"] + pkgshare.install "KLU/Demo/klu_simple.c" + end + + test do + system ENV.cc, "-o", "test", pkgshare/"klu_simple.c", + "-L#{lib}", "-lsuitesparseconfig", "-lklu" + assert_predicate testpath/"test", :exist? + assert_match "x [0] = 1", shell_output("./test") + end +end