git: 20b1cb36dae1 - main - math/ceres-solver: chase the upgrade of SuiteSparse

From: Thierry Thomas <thierry_at_FreeBSD.org>
Date: Sun, 27 Nov 2022 11:10:25 UTC
The branch main has been updated by thierry:

URL: https://cgit.FreeBSD.org/ports/commit/?id=20b1cb36dae15be1adeb92f297b5815151999029

commit 20b1cb36dae15be1adeb92f297b5815151999029
Author:     Thierry Thomas <thierry@FreeBSD.org>
AuthorDate: 2022-11-26 18:54:41 +0000
Commit:     Thierry Thomas <thierry@FreeBSD.org>
CommitDate: 2022-11-27 11:09:57 +0000

    math/ceres-solver: chase the upgrade of SuiteSparse
    
    Patch from upstream
    <https://github.com/ceres-solver/ceres-solver/issues/919>.
    
    PR:             267746
    Approved by:    yuri (maintainer)
    Obtained from:  https://github.com/ceres-solver/ceres-solver/issues/919
---
 math/ceres-solver/Makefile                         |  1 +
 .../files/patch-cmake_FindSuiteSparse.cmake        | 52 ++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/math/ceres-solver/Makefile b/math/ceres-solver/Makefile
index 1eda7ad4680f..0a1cad198ccc 100644
--- a/math/ceres-solver/Makefile
+++ b/math/ceres-solver/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	ceres-solver
 DISTVERSION=	2.1.0
+PORTREVISION=	1
 CATEGORIES=	math
 
 MAINTAINER=	yuri@FreeBSD.org
diff --git a/math/ceres-solver/files/patch-cmake_FindSuiteSparse.cmake b/math/ceres-solver/files/patch-cmake_FindSuiteSparse.cmake
new file mode 100644
index 000000000000..a5a9781b6f6b
--- /dev/null
+++ b/math/ceres-solver/files/patch-cmake_FindSuiteSparse.cmake
@@ -0,0 +1,52 @@
+--- cmake/FindSuiteSparse.cmake.orig	2022-03-28 14:02:35 UTC
++++ cmake/FindSuiteSparse.cmake
+@@ -394,26 +394,36 @@ if (TARGET SuiteSparse::Config)
+   else (NOT EXISTS ${SuiteSparse_VERSION_FILE})
+     file(READ ${SuiteSparse_VERSION_FILE} Config_CONTENTS)
+ 
+-    string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION [0-9]+"
+-      SuiteSparse_VERSION_MAJOR "${Config_CONTENTS}")
+-    string(REGEX REPLACE "#define SUITESPARSE_MAIN_VERSION ([0-9]+)" "\\1"
+-      SuiteSparse_VERSION_MAJOR "${SuiteSparse_VERSION_MAJOR}")
++    string(REGEX MATCH "#define SUITESPARSE_MAIN_VERSION[ \t]+([0-9]+)"
++      SuiteSparse_VERSION_LINE "${Config_CONTENTS}")
++    set (SuiteSparse_VERSION_MAJOR ${CMAKE_MATCH_1})
+ 
+-    string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION [0-9]+"
+-      SuiteSparse_VERSION_MINOR "${Config_CONTENTS}")
+-    string(REGEX REPLACE "#define SUITESPARSE_SUB_VERSION ([0-9]+)" "\\1"
+-      SuiteSparse_VERSION_MINOR "${SuiteSparse_VERSION_MINOR}")
++    string(REGEX MATCH "#define SUITESPARSE_SUB_VERSION[ \t]+([0-9]+)"
++      SuiteSparse_VERSION_LINE "${Config_CONTENTS}")
++    set (SuiteSparse_VERSION_MINOR ${CMAKE_MATCH_1})
+ 
+-    string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION [0-9]+"
+-      SuiteSparse_VERSION_PATCH "${Config_CONTENTS}")
+-    string(REGEX REPLACE "#define SUITESPARSE_SUBSUB_VERSION ([0-9]+)" "\\1"
+-      SuiteSparse_VERSION_PATCH "${SuiteSparse_VERSION_PATCH}")
++    string(REGEX MATCH "#define SUITESPARSE_SUBSUB_VERSION[ \t]+([0-9]+)"
++      SuiteSparse_VERSION_LINE "${Config_CONTENTS}")
++    set (SuiteSparse_VERSION_PATCH ${CMAKE_MATCH_1})
+ 
++    unset (SuiteSparse_VERSION_LINE)
++
+     # This is on a single line s/t CMake does not interpret it as a list of
+     # elements and insert ';' separators which would result in 4.;2.;1 nonsense.
+     set(SuiteSparse_VERSION
+       "${SuiteSparse_VERSION_MAJOR}.${SuiteSparse_VERSION_MINOR}.${SuiteSparse_VERSION_PATCH}")
+-    set(SuiteSparse_VERSION_COMPONENTS 3)
++
++    if (SuiteSparse_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
++      set(SuiteSparse_VERSION_COMPONENTS 3)
++    else (SuiteSparse_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
++      message (WARNING "Could not parse SuiteSparse_config.h: SuiteSparse "
++        "version will not be available")
++
++      unset (SuiteSparse_VERSION)
++      unset (SuiteSparse_VERSION_MAJOR)
++      unset (SuiteSparse_VERSION_MINOR)
++      unset (SuiteSparse_VERSION_PATCH)
++    endif (SuiteSparse_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
+   endif (NOT EXISTS ${SuiteSparse_VERSION_FILE})
+ endif (TARGET SuiteSparse::Config)
+