Bug 239654 - devel/googletest and devel/googlemock: Change build to use CMake
Summary: devel/googletest and devel/googlemock: Change build to use CMake
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Jan Beich
Depends on:
Reported: 2019-08-05 11:31 UTC by Ben Woods
Modified: 2019-10-06 16:36 UTC (History)
1 user (show)

See Also:
woodsb02: maintainer-feedback+

Patch to change devel/googletest and devel/googlemock to use CMake (10.02 KB, patch)
2019-08-05 11:31 UTC, Ben Woods
jbeich: maintainer-approval-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Woods freebsd_committer 2019-08-05 11:31:22 UTC
Created attachment 206291 [details]
Patch to change devel/googletest and devel/googlemock to use CMake

devel/googletest and devel/googlemock: Change build to use CMake

The latest (master) version of Google Test has now fully moved to using CMake for the configure process, with all support from GNU configure removed. The latest RELEASED version (1.8.1) has introduced support for CMake, but still had GNU configure support also.

Interestingly, this change has the following impact on installed files:
1. The pkg-config files are installed with CMake
2. The bin/gtest-config and bin/gmock-config files cannot be installed, as the shell script is not compiled from the "*.in" files in googletest/scripts/gtest-config.in and googlemock/scripts/gmock-config.in
Comment 1 Jan Beich freebsd_committer 2019-08-11 09:15:52 UTC
Comment on attachment 206291 [details]
Patch to change devel/googletest and devel/googlemock to use CMake

Previous try was in review D19430.

> Index: devel/googlemock/Makefile
> -USES=		autoreconf compiler:c++11-lang libtool localbase python:run shebangfix
> +USES=		cmake compiler:c++11-lang libtool localbase python:run shebangfix

Is USES=localbase still required? If so add :ldflags as CMake rarely supports LIBS variable.

>  TEST_TARGET=	check

Does "make test" still work? If not adjust and make sure tests are built (e.g., via an option).

> +STRIP=		yes

Already defined, see /usr/share/mk/bsd.own.mk. Ditto in googletest.


Convert to CMAKE_ON/CMAKE_OFF. Ditto in googletest.
> +	find "${STAGEDIR}" -name '*.pump' -print0 | xargs -0 rm -v

Why not ${FIND} ${STAGEDIR} -name '*.pump' -delete ? Needs to be reported upstream. Ditto in googletest.

> +	${RM} -r ${STAGEDIR}${PREFIX}/include/gtest \
> +		${STAGEDIR}${PREFIX}/lib/cmake \
> +		${STAGEDIR}${PREFIX}/lib/libgtest* \
> +		${STAGEDIR}${PREFIX}/libdata/pkgconfig/gtest*

Why not drop "add_subdirectory( googletest )" in CMakeLists.txt or at least mark as EXCLUDE_FROM_ALL?
> -lib/libgmock.a
>  lib/libgmock.so
> -lib/libgmock.so.0
> -lib/libgmock.so.0.0.0
> -lib/libgmock_main.a
>  lib/libgmock_main.so
> -lib/libgmock_main.so.0
> -lib/libgmock_main.so.0.0.0

- SONAME has changed, so all consumers need PORTREVISION bump
- Static library is gone, so consumers need to be tested
- Ditto in googletest

> Index: devel/googletest/Makefile
> +	${INSTALL_DATA} ${WRKSRC}/googletest/m4/gtest.m4 ${STAGEDIR}${PREFIX}/share/aclocal
If unused by consumers just drop the file.

> -bin/gtest-config

OK but you have to fix consumers. There're 3 types: used by default, used if an option is set and used only via "make test".

> +include/gtest/internal/custom/README.md

README.md isn't part of API. Needs to be reported upstream.

> +lib/cmake/GTest/GTestConfig.cmake
> +lib/cmake/GTest/GTestConfigVersion.cmake
> +lib/cmake/GTest/GTestTargets-%%CMAKE_BUILD_TYPE%%.cmake
> +lib/cmake/GTest/GTestTargets.cmake

Why googlemock doesn't install CMake configs?
Comment 2 Jan Beich freebsd_committer 2019-08-11 09:54:46 UTC
autotools is gone[1], so cmake switch have to be done during the next update[2]. Hopefully, some cmake bugs were fixed.

[1] http://github.com/google/googletest/commit/d7003576dd13
[2] maybe master snapshot given how upstream looks at stable releases
Comment 3 Ben Woods freebsd_committer 2019-08-12 10:52:25 UTC
Will wait until next update to change
Comment 4 commit-hook freebsd_committer 2019-10-05 00:43:08 UTC
A commit references this bug:

Author: jbeich
Date: Sat Oct  5 00:42:24 UTC 2019
New revision: 513801
URL: https://svnweb.freebsd.org/changeset/ports/513801

  devel/google{test,mock}: update to 1.10.0

  - Drop static library
  - Drop gtest-config and gmock-config
  - Drop GTEST_LIB_CHECK autoconf macro
  - Drop gmock_doctory.py as it's too old
  - Expose tests via option

  Changes:	https://github.com/google/googletest/compare/release-1.8.1...release-1.10.0
  Reported by:	GitHub (watch releases)
  PR:		239654
  Differential Revision:	https://reviews.freebsd.org/D19430