From 1897fc94e0bca9c26dac8d134d59554fd8a797aa Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Mon, 10 Aug 2026 23:22:07 -0400 Subject: [PATCH 1/3] Bump googletest to v1.18.0 --- M2/libraries/gtest/Makefile.in | 2 +- M2/submodules/googletest | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/M2/libraries/gtest/Makefile.in b/M2/libraries/gtest/Makefile.in index 280ce811e82..c08f72c5a44 100644 --- a/M2/libraries/gtest/Makefile.in +++ b/M2/libraries/gtest/Makefile.in @@ -1,7 +1,7 @@ SUBMODULE = true LIBNAME = googletest URL = https://github.com/google/googletest -VERSION = 1.16.0 +VERSION = 1.18.0 CONFIGURECMD = cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DBUILD_GMOCK=OFF \ -DCMAKE_INSTALL_LIBDIR=lib diff --git a/M2/submodules/googletest b/M2/submodules/googletest index 6910c9d9165..063de7e9578 160000 --- a/M2/submodules/googletest +++ b/M2/submodules/googletest @@ -1 +1 @@ -Subproject commit 6910c9d9165801d8827d628cb72eb7ea9dd538c5 +Subproject commit 063de7e9578f82b369302001269680b4b1553359 From b1c7105521967459edd520bea8c3c49f8dce575a Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Tue, 11 Aug 2026 07:36:34 -0400 Subject: [PATCH 2/3] Clear stale _DIR before searching for libraries we build ourselves A cached _DIR outranks CMAKE_PREFIX_PATH for as long as it still satisfies the requested version, so once one is set, find_package keeps returning the copy on the system even after we have installed our own into M2_HOST_PREFIX, which comes first in the prefix path. This broke BUILD_LIBRARIES=gtest. memtailor, mathic and mathicgb each guard their own find_package(GTest) with "if(NOT GTEST_FOUND)", which fires exactly when check-libraries has unset GTEST_FOUND to request a self-build, and that re-caches GTest_DIR pointing at the system copy after the loop below has cleared it. check-libraries then reads that stale value at the top of the next configure and unsets GTEST_FOUND again, so the reconfigure driven by the build-libraries target never converged: Macaulay2/e/CMakeLists.txt skipped target_link_libraries(M2-unit-tests GTest::GTest GTest::Main) every time and M2-unit-tests failed to link with undefined testing:: symbols. Only builds against a system googletest of 1.16 or newer were affected, which is why this showed up on macOS (Homebrew has 1.18.0) but not on Ubuntu, where libgtest-dev is 1.14.0: there the cached GTest_DIR fails the version check in find_package(GTest 1.16) and cmake carries on searching, finding our own copy under M2_HOST_PREFIX by itself. GTest is the only entry of LIBRARY_OPTIONS that anything else calls find_package on, so it is the only one that could not converge, but clear the stale entry for every library we intend to build rather than special-casing. BUILD_LIBRARIES is now folded to upper case once here rather than once per iteration of the loop below, which is left in place so that it does not depend on this one having run. Co-Authored-By: Claude Opus 5 --- M2/cmake/check-libraries.cmake | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/M2/cmake/check-libraries.cmake b/M2/cmake/check-libraries.cmake index e676fe52b95..99a4b90e40f 100644 --- a/M2/cmake/check-libraries.cmake +++ b/M2/cmake/check-libraries.cmake @@ -142,6 +142,20 @@ find_package(GMP 6.0.0 REQUIRED) # givaro prime field and algebraic computations (needs gmp) # fflas_ffpack Finite Field Linear Algebra Routines (needs gmp, givaro + LAPACK) +set(LIBRARY_OPTIONS + Eigen3 BDWGC MPFR MPFI NTL Flint Factory Frobby cddlib MPSolve + GTest GLPK Givaro FFLAS_FFPACK Normaliz) + +# A cached _DIR outranks CMAKE_PREFIX_PATH, so drop it for anything we +# intend to build ourselves before searching for it below. +string(TOUPPER "${BUILD_LIBRARIES}" BUILD_LIBRARIES) +foreach(_library IN LISTS LIBRARY_OPTIONS) + string(TOUPPER "${_library}" _name) + if(BUILD_LIBRARIES MATCHES "(ALL|ON)" OR "${_name}" IN_LIST BUILD_LIBRARIES) + unset(${_library}_DIR CACHE) + endif() +endforeach() + # Prior to 3.4.1, find_package for Eigen3 doesn't support version ranges # but Ubuntu only has 3.4.0 right now, so we should support it # For Eigen 5.0 and later, the way the version checking is setup, specifying @@ -180,10 +194,6 @@ pkg_search_module(FFLAS_FFPACK IMPORTED_TARGET fflas-ffpack>=2.4.3) pkg_search_module(GIVARO IMPORTED_TARGET givaro>=4.1.1) # TODO: add FindModules for these two as well -set(LIBRARY_OPTIONS - Eigen3 BDWGC MPFR MPFI NTL Flint Factory Frobby cddlib MPSolve - GTest GLPK Givaro FFLAS_FFPACK Normaliz) - ############################################################################### ## Optional libraries: # LibXML2 libxml2-dev libxml2-devel N/A From 1c5a9d3d1587da2f0df1a40cebf039351765767d Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Tue, 11 Aug 2026 08:17:04 -0400 Subject: [PATCH 3/3] Refresh the distributed gftables when GFTABLESDIR moves The copy was guarded only on the destination not already existing, so it happened once, on the first configure -- at which point GFTABLESDIR still points at the factory that was already on the system. With BUILD_LIBRARIES=factory, GFTABLESDIR moves to M2_HOST_PREFIX on the reconfigure that the build-libraries target performs, but the destination exists by then and the tables we just built were never picked up, so we distributed the system's tables alongside our own factory. Copy again when GFTABLESDIR differs from wherever we last copied from, and remove the previous copy first: file(COPY) optimizes out files whose timestamps match, and it compares them at a coarser resolution than it writes them, so it will not reliably replace the earlier tables in place. Removing first also drops any tables that are no longer present upstream. Co-Authored-By: Claude Opus 5 --- M2/cmake/build-libraries.cmake | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/M2/cmake/build-libraries.cmake b/M2/cmake/build-libraries.cmake index c0dea73115e..122a6d0aeb2 100644 --- a/M2/cmake/build-libraries.cmake +++ b/M2/cmake/build-libraries.cmake @@ -415,10 +415,17 @@ ExternalProject_Add(build-factory TEST_EXCLUDE_FROM_MAIN ON STEP_TARGETS install test ) -if(GFTABLESDIR AND NOT EXISTS ${M2_DIST_PREFIX}/${M2_INSTALL_DATADIR}/Core/factory/gftables) +# Copy again when GFTABLESDIR moves, so that building factory ourselves replaces +# the tables copied from the version already on the system. +set(GFTABLES_DEST ${M2_DIST_PREFIX}/${M2_INSTALL_DATADIR}/Core/factory) +if(GFTABLESDIR AND (NOT EXISTS ${GFTABLES_DEST}/gftables + OR NOT "${GFTABLESDIR}" STREQUAL "${GFTABLES_COPIED_FROM}")) message(STATUS "Copying gftables from ${GFTABLESDIR}/gftables") - file(COPY ${GFTABLESDIR}/gftables - DESTINATION ${M2_DIST_PREFIX}/${M2_INSTALL_DATADIR}/Core/factory FOLLOW_SYMLINK_CHAIN) + # clear the previous copy first; file(COPY) skips files whose timestamps match + file(REMOVE_RECURSE ${GFTABLES_DEST}/gftables) + file(COPY ${GFTABLESDIR}/gftables DESTINATION ${GFTABLES_DEST} FOLLOW_SYMLINK_CHAIN) + set(GFTABLES_COPIED_FROM "${GFTABLESDIR}" + CACHE INTERNAL "directory the distributed gftables were copied from") endif() _ADD_COMPONENT_DEPENDENCY(libraries factory "gmp;ntl;flint" FACTORY_FOUND)