Bug 239654

Summary: devel/googletest and devel/googlemock: Change build to use CMake
Product: Ports & Packages Reporter: Ben Woods <woodsb02>
Component: Individual Port(s)Assignee: Jan Beich <jbeich>
Status: Closed FIXED    
Severity: Affects Only Me CC: jbeich
Priority: --- Flags: woodsb02: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch to change devel/googletest and devel/googlemock to use CMake jbeich: maintainer-approval-

Description Ben Woods freebsd_committer freebsd_triage 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 freebsd_triage 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.

> +CMAKE_ARGS=	-DBUILD_SHARED_LIBS:BOOL=ON \
> +		-DBUILD_GMOCK:BOOL=ON

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 freebsd_triage 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
    https://github.com/google/googletest/issues/2267
Comment 3 Ben Woods freebsd_committer freebsd_triage 2019-08-12 10:52:25 UTC
Will wait until next update to change
Comment 4 commit-hook freebsd_committer freebsd_triage 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

Log:
  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

Changes:
  head/databases/clickhouse/Makefile
  head/devel/android-tools-adb/files/Makefile
  head/devel/android-tools-simpleperf/files/Makefile
  head/devel/googlemock/Makefile
  head/devel/googlemock/distinfo
  head/devel/googlemock/files/
  head/devel/googlemock/pkg-plist
  head/devel/googletest/Makefile
  head/devel/googletest/distinfo
  head/devel/googletest/files/
  head/devel/googletest/pkg-plist
  head/devel/msgpack/Makefile
  head/finance/gnucash/Makefile
  head/lang/cling/Makefile
  head/math/yacas/Makefile
  head/net-im/mtxclient/Makefile
  head/science/libkml/Makefile
  head/security/certificate-transparency/Makefile