development/gtest: Updated for version 1.14.0.

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
Dimitris Zlatanidis 2024-01-03 21:49:48 +02:00 committed by Willy Sudiarto Raharjo
parent 80d0e64ee0
commit 8862063272
No known key found for this signature in database
GPG Key ID: 3F617144D7238786
4 changed files with 21 additions and 260 deletions

View File

@ -2,8 +2,8 @@
# Slackware build script for gtest # Slackware build script for gtest
# Copyright 2016-2024 Dimitris Zlatanidis Orestiada, Greece
# 2013-02-12 Bernski Comadizo <bcomadizo@gmail.com> Cebu # 2013-02-12 Bernski Comadizo <bcomadizo@gmail.com> Cebu
# Copyright 2016 Dimitris Zlatanidis Orestiada, Greece
# #
# All rights reserved. # All rights reserved.
# #
@ -24,19 +24,14 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 20220415 bkw: Modified by SlackBuilds.org, BUILD=4:
# - install (or actually symlink) docs to /usr/doc/$PRGNAM-$VERSION,
# to follow Slackware standards.
# - install shared libraries with +x permission.
cd $(dirname $0) ; CWD=$(pwd) cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=gtest PRGNAM=gtest
SRCNAM=googletest SRCNAM=googletest
VERSION=${VERSION:-1.10.0} VERSION=${VERSION:-1.14.0}
BUILD=${BUILD:-4} BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz} PKGTYPE=${PKGTYPE:-tgz}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then if [ -z "$ARCH" ]; then
case "$( uname -m )" in case "$( uname -m )" in
@ -74,17 +69,15 @@ set -e
rm -rf $PKG rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT mkdir -p $TMP $PKG $OUTPUT
cd $TMP cd $TMP
rm -rf $SRCNAM-release-$VERSION rm -rf $SRCNAM-$VERSION
tar -xvf $CWD/$SRCNAM-release-$VERSION.tar.gz tar -xvf $CWD/$SRCNAM-$VERSION.tar.gz
cd $SRCNAM-release-$VERSION cd $SRCNAM-$VERSION
chown -R root:root . chown -R root:root .
find -L . \ find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \+ -o \ -o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
for i in $CWD/patches/* ; do patch -p1 < $i ; done
mkdir -p build mkdir -p build
cd build cd build
@ -113,7 +106,7 @@ install -m 0644 googletest/include/$PRGNAM/internal/custom/*.h \
$PKG/usr/include/$PRGNAM/internal/custom $PKG/usr/include/$PRGNAM/internal/custom
# install the libs and the pkgconfig files! # install the libs and the pkgconfig files!
install -s -m 0755 build/lib/*.so $PKG/usr/lib$LIBDIRSUFFIX install -m 0755 build/lib/*.so $PKG/usr/lib$LIBDIRSUFFIX
mkdir -p $PKG/usr/lib$LIBDIRSUFFIX/pkgconfig mkdir -p $PKG/usr/lib$LIBDIRSUFFIX/pkgconfig
for i in gmock gmock_main gtest gtest_main ; do for i in gmock gmock_main gtest gtest_main ; do
sed "s| -lpthread||g" build/googletest/generated/${i}.pc \ sed "s| -lpthread||g" build/googletest/generated/${i}.pc \
@ -123,21 +116,16 @@ done
mkdir -p $PKG/usr/src mkdir -p $PKG/usr/src
cp -R googlemock $PKG/usr/src cp -R googlemock $PKG/usr/src
cp -R googletest $PKG/usr/src cp -R googletest $PKG/usr/src
# Create symlinks as some programs look for the shorter names # Create symlinks as some programs look for the shorter names
(cd $PKG/usr/src ; ln -svf googlemock gmock ; ln -svf googletest gtest) (cd $PKG/usr/src ; ln -svf googlemock gmock ; ln -svf googletest gtest)
# 20220415 bkw: the docs get installed in /usr/src along with find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
# everything else. symlink them to a place that slackware users | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
# expect to see them.
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC cp -a README.md LICENSE $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
for dir in googlemock googletest; do
mkdir -p $PKGDOC/$dir
for file in CONTRIBUTORS LICENSE README.md docs samples; do
[ -e $PKG/usr/src/$dir/$file ] && ln -s ../../../src/$dir/$file $PKGDOC/$dir
done
done
mkdir -p $PKG/install mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/slack-desc > $PKG/install/slack-desc

View File

@ -1,10 +1,10 @@
PRGNAM="gtest" PRGNAM="gtest"
VERSION="1.10.0" VERSION="1.14.0"
HOMEPAGE="https://github.com/google/googletest" HOMEPAGE="https://github.com/google/googletest"
DOWNLOAD="https://github.com/google/googletest/archive/release-1.10.0/googletest-release-1.10.0.tar.gz" DOWNLOAD="https://github.com/google/googletest/archive/v1.14.0/googletest-1.14.0.tar.gz"
MD5SUM="ecd1fa65e7de707cd5c00bdac56022cd" MD5SUM="c8340a482851ef6a3fe618a082304cfc"
DOWNLOAD_x86_64="" DOWNLOAD_x86_64=""
MD5SUM_x86_64="" MD5SUM_x86_64=""
REQUIRES="" REQUIRES=""
MAINTAINER="Dimitris Zlatanidis" MAINTAINER="Dimitris Zlatanidis"
EMAIL="d.zlatanidis@gmail.com" EMAIL="dslackw@gmail.com"

View File

@ -1,166 +0,0 @@
From 5126ff48d9ac54828d1947d1423a5ef2a8efee3b Mon Sep 17 00:00:00 2001
From: David Seifert <soap@gentoo.org>
Date: Sat, 5 Oct 2019 15:58:45 +0200
Subject: [PATCH 1/2] Revert "Use pcfiledir for prefix in pkgconfig file"
The change makes implicit assumptions on the layout of the install
tree, which is going to break in many ways.
The correct solution is to use the `PKG_CONFIG_SYSROOT_DIR` variable
to inject the cross-compiled sysroot into `-I` and `-L` paths.
---
googlemock/cmake/gmock.pc.in | 5 ++---
googlemock/cmake/gmock_main.pc.in | 5 ++---
googletest/cmake/gtest.pc.in | 5 ++---
googletest/cmake/gtest_main.pc.in | 5 ++---
4 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/googlemock/cmake/gmock.pc.in b/googlemock/cmake/gmock.pc.in
index 08e045474..2ef0fbca1 100644
--- a/googlemock/cmake/gmock.pc.in
+++ b/googlemock/cmake/gmock.pc.in
@@ -1,6 +1,5 @@
-prefix=${pcfiledir}/../..
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: gmock
Description: GoogleMock (without main() function)
diff --git a/googlemock/cmake/gmock_main.pc.in b/googlemock/cmake/gmock_main.pc.in
index b22fe6148..04658fe2e 100644
--- a/googlemock/cmake/gmock_main.pc.in
+++ b/googlemock/cmake/gmock_main.pc.in
@@ -1,6 +1,5 @@
-prefix=${pcfiledir}/../..
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: gmock_main
Description: GoogleMock (with main() function)
diff --git a/googletest/cmake/gtest.pc.in b/googletest/cmake/gtest.pc.in
index 9aae29e26..e7967ad56 100644
--- a/googletest/cmake/gtest.pc.in
+++ b/googletest/cmake/gtest.pc.in
@@ -1,6 +1,5 @@
-prefix=${pcfiledir}/../..
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: gtest
Description: GoogleTest (without main() function)
diff --git a/googletest/cmake/gtest_main.pc.in b/googletest/cmake/gtest_main.pc.in
index 915f2973a..fe25d9c73 100644
--- a/googletest/cmake/gtest_main.pc.in
+++ b/googletest/cmake/gtest_main.pc.in
@@ -1,6 +1,5 @@
-prefix=${pcfiledir}/../..
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: gtest_main
Description: GoogleTest (with main() function)
From b96832a44b4994cafc824f200d69232d79f30d81 Mon Sep 17 00:00:00 2001
From: David Seifert <soap@gentoo.org>
Date: Sat, 5 Oct 2019 15:58:48 +0200
Subject: [PATCH 2/2] Add documentation for pkg-config in cross-compilation
settings
---
googletest/docs/pkgconfig.md | 78 ++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/googletest/docs/pkgconfig.md b/googletest/docs/pkgconfig.md
index 6dc067388..d5f361448 100644
--- a/googletest/docs/pkgconfig.md
+++ b/googletest/docs/pkgconfig.md
@@ -139,3 +139,81 @@ export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
```
pkg-config will also try to look in `PKG_CONFIG_PATH` to find `gtest_main.pc`.
+
+### Using pkg-config in a cross-compilation setting
+
+Pkg-config can be used in a cross-compilation setting too. To do this, let's
+assume the final prefix of the cross-compiled installation will be `/usr`,
+and your sysroot is `/home/MYUSER/sysroot`. Configure and install GTest using
+
+```
+mkdir build && cmake -DCMAKE_INSTALL_PREFIX=/usr ..
+```
+
+Install into the sysroot using `DESTDIR`:
+
+```
+make -j install DESTDIR=/home/MYUSER/sysroot
+```
+
+Before we continue, it is recommended to **always** define the following two
+variables for pkg-config in a cross-compilation setting:
+
+```
+export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=yes
+export PKG_CONFIG_ALLOW_SYSTEM_LIBS=yes
+```
+
+otherwise `pkg-config` will filter `-I` and `-L` flags against standard
+prefixes such as `/usr` (see https://bugs.freedesktop.org/show_bug.cgi?id=28264#c3
+for reasons why this stripping needs to occur usually).
+
+If you look at the generated pkg-config file, it will look something like
+
+```
+libdir=/usr/lib64
+includedir=/usr/include
+
+Name: gtest
+Description: GoogleTest (without main() function)
+Version: 1.10.0
+URL: https://github.com/google/googletest
+Libs: -L${libdir} -lgtest -lpthread
+Cflags: -I${includedir} -DGTEST_HAS_PTHREAD=1 -lpthread
+```
+
+Notice that the sysroot is not included in `libdir` and `includedir`! If you
+try to run `pkg-config` with the correct
+`PKG_CONFIG_LIBDIR=/home/MYUSER/sysroot/usr/lib64/pkgconfig` against this `.pc`
+file, you will get
+
+```
+$ pkg-config --cflags gtest
+-DGTEST_HAS_PTHREAD=1 -lpthread -I/usr/include
+$ pkg-config --libs gtest
+-L/usr/lib64 -lgtest -lpthread
+```
+
+which is obviously wrong and points to the `CBUILD` and not `CHOST` root.
+In order to use this in a cross-compilation setting, we need to tell
+pkg-config to inject the actual sysroot into `-I` and `-L` variables. Let us
+now tell pkg-config about the actual sysroot
+
+```
+export PKG_CONFIG_DIR=
+export PKG_CONFIG_SYSROOT_DIR=/home/MYUSER/sysroot
+export PKG_CONFIG_LIBDIR=${PKG_CONFIG_SYSROOT_DIR}/usr/lib64/pkgconfig
+```
+
+and running `pkg-config` again we get
+
+```
+$ pkg-config --cflags gtest
+-DGTEST_HAS_PTHREAD=1 -lpthread -I/home/MYUSER/sysroot/usr/include
+$ pkg-config --libs gtest
+-L/home/MYUSER/sysroot/usr/lib64 -lgtest -lpthread
+```
+
+which contains the correct sysroot now. For a more comprehensive guide to
+also including `${CHOST}` in build system calls, see the excellent tutorial
+by Diego Elio Pettenò: https://autotools.io/pkgconfig/cross-compiling.html

View File

@ -1,61 +0,0 @@
From 6caa879a42d97f1b02ecc90c77fc486220251fa1 Mon Sep 17 00:00:00 2001
From: Martin Erik Werner <martinerikwerner@gmail.com>
Date: Sat, 19 Oct 2019 19:37:16 +0200
Subject: [PATCH] pkg-config: Remove pthread link flag from Cflags
Remove the threads link library variable references from the pkg-config
Cflags: field, removing -lpthread(s) from the compile flags.
"-l*" linker flags should only be part of the Libs: section and should
not be part of the Cflags: section in pkg-config files.
This was first suggested in
https://github.com/google/googletest/pull/2006 and further discussed in
https://github.com/google/googletest/pull/2483 .
---
googlemock/cmake/gmock.pc.in | 2 +-
googlemock/cmake/gmock_main.pc.in | 2 +-
googletest/cmake/gtest.pc.in | 2 +-
googletest/cmake/gtest_main.pc.in | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/googlemock/cmake/gmock.pc.in b/googlemock/cmake/gmock.pc.in
index 08e045474..99eb3e178 100644
--- a/googlemock/cmake/gmock.pc.in
+++ b/googlemock/cmake/gmock.pc.in
@@ -8,4 +8,4 @@ Version: @PROJECT_VERSION@
URL: https://github.com/google/googletest
Requires: gtest
Libs: -L${libdir} -lgmock @CMAKE_THREAD_LIBS_INIT@
-Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@
+Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
diff --git a/googlemock/cmake/gmock_main.pc.in b/googlemock/cmake/gmock_main.pc.in
index b22fe6148..3186f8edc 100644
--- a/googlemock/cmake/gmock_main.pc.in
+++ b/googlemock/cmake/gmock_main.pc.in
@@ -8,4 +8,4 @@ Version: @PROJECT_VERSION@
URL: https://github.com/google/googletest
Requires: gmock
Libs: -L${libdir} -lgmock_main @CMAKE_THREAD_LIBS_INIT@
-Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@
+Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
diff --git a/googletest/cmake/gtest.pc.in b/googletest/cmake/gtest.pc.in
index 9aae29e26..49d70c9bb 100644
--- a/googletest/cmake/gtest.pc.in
+++ b/googletest/cmake/gtest.pc.in
@@ -7,4 +7,4 @@ Description: GoogleTest (without main() function)
Version: @PROJECT_VERSION@
URL: https://github.com/google/googletest
Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@
-Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@
+Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
diff --git a/googletest/cmake/gtest_main.pc.in b/googletest/cmake/gtest_main.pc.in
index 915f2973a..e0d81a8d6 100644
--- a/googletest/cmake/gtest_main.pc.in
+++ b/googletest/cmake/gtest_main.pc.in
@@ -8,4 +8,4 @@ Version: @PROJECT_VERSION@
URL: https://github.com/google/googletest
Requires: gtest
Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@
-Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@
+Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@