summaryrefslogtreecommitdiffstats
path: root/m4macros/ax_gtest.m4
diff options
context:
space:
mode:
authorPiotrek Zadroga <piotrek@isc.org>2023-09-22 21:07:33 +0200
committerPiotrek Zadroga <piotrek@isc.org>2023-10-04 19:36:20 +0200
commita181b29c91bcecb4c068129db398a7d7741fd6a1 (patch)
tree5af80829c09a6bc8ba4d593a434949cb6217aa96 /m4macros/ax_gtest.m4
parent[#3078] set package version and type in configure.ac (diff)
downloadkea-a181b29c91bcecb4c068129db398a7d7741fd6a1.tar.xz
kea-a181b29c91bcecb4c068129db398a7d7741fd6a1.zip
[#3065] gtest version regex check
Diffstat (limited to 'm4macros/ax_gtest.m4')
-rw-r--r--m4macros/ax_gtest.m423
1 files changed, 20 insertions, 3 deletions
diff --git a/m4macros/ax_gtest.m4 b/m4macros/ax_gtest.m4
index 2681b4314c..4cb2d192a9 100644
--- a/m4macros/ax_gtest.m4
+++ b/m4macros/ax_gtest.m4
@@ -71,7 +71,7 @@ if test "x$enable_gtest" = "xyes" ; then
AC_MSG_CHECKING([for gtest source])
# If not specified, try some common paths.
GTEST_SOURCE=
- for d in /usr/src/gtest /usr/local /usr/pkg /opt /opt/local ; do
+ for d in /usr/src/googletest/googletest /usr/src/gtest /usr/local /usr/pkg /opt /opt/local ; do
if test -f $d/src/gtest-all.cc -a $d/src/gtest_main.cc; then
GTEST_SOURCE=$d
AC_MSG_RESULT([$GTEST_SOURCE])
@@ -98,14 +98,31 @@ if test "x$enable_gtest" = "xyes" ; then
GTEST_INCLUDES="-I$GTEST_SOURCE -I$GTEST_SOURCE/include"
GTEST_VERSION="`basename $GTEST_SOURCE`"
-# Versions starting from 1.8.0 are put in the googletest directory. If the basename
-# returns googletest string, we need to cut it off and try baseline again.
+ # Versions starting from 1.8.0 are put in the googletest directory. If the basename
+ # returns googletest string, we need to cut it off and try baseline again.
if test "$GTEST_VERSION" = "googletest"; then
GTEST_VERSION=${GTEST_SOURCE%"/googletest"}
GTEST_VERSION=`basename $GTEST_VERSION`
fi
GTEST_VERSION="${GTEST_VERSION#googletest-release-}"
GTEST_VERSION="${GTEST_VERSION#gtest-}"
+ GTEST_VERSION="${GTEST_VERSION#googletest-}"
+
+ # If the GTEST_VERSION is still not correct semver, we need to determine googletest version in other way.
+ # Let's try to extract it from CMake build script used by Google Test.
+ # semverRegex='\([[:digit:]]\{1,\}\)\{0,1\}\(.[[:digit:]]\{1,\}\)\{0,1\}\(.[[:digit:]]\{1,\}\)\{0,1\}\(.[[:digit:]]\{1,\}\)\{0,1\}'
+ semverRegex='^\(v\{0,1\}\)\([[:digit:]]\{1,\}\)\{0,1\}\(.[[:digit:]]\{1,\}\)\{0,1\}\(.[[:digit:]]\{1,\}\)\{0,1\}\(.[[:digit:]]\{1,\}\)\{0,1\}\(.\{0,\}\)$'
+
+ semver_found_len=
+ semver_found_len=`expr ${GTEST_VERSION} : "${semverRegex}"`
+
+ if test -z $semver_found_len || "$semver_found_len" = "0"; then
+ # AC_MSG_NOTICE([case 1])
+ GTEST_VERSION=`grep "set(GOOGLETEST_VERSION" -h $GTEST_SOURCE/* 2>/dev/null | cut -d' ' -f2 | sed 's/)//'`
+ else
+ # AC_MSG_NOTICE([case 2])
+ fi
+ # AC_MSG_RESULT([GTEST_VERSION $GTEST_VERSION])
fi
if test "$gtest_path" != "no" ; then