Skip to contentSkip to conversation

gtest: update recipe to use autotools

PATCH Superseded Carlos Santos 4 participants 8 messages Mar 2, 2015 – Apr 25, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gtest: update recipe to use autotools

The previous recipe build gtest using cmake, which prevented compiling gmock (to be submitted in a following patch).

Gmock requires the gtest-config script, which is installed only if gtest is built with autotools.

---
 package/gtest/gtest.mk | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
package/gtest/gtest.mk +4 -12
index 7129c93..e148462 100644
@@ -12,24 +12,16 @@ GTEST_INSTALL_TARGET = NO
 GTEST_LICENSE = BSD-3c
 GTEST_LICENSE_FILES = LICENSE
 
-# While it is possible to build gtest as shared library, using this gtest shared
-# library requires to set some special configure option in the project using
-# gtest.
-# So, force to build gtest as a static library.
-#
-# For further details, refer to the explaination given in the README file from
-# the gtest sources.
-GTEST_CONF_OPTS = -DBUILD_SHARED_LIBS=OFF
-
 define GTEST_EXTRACT_CMDS
 	$(UNZIP) $(DL_DIR)/$(GTEST_SOURCE) -d $(BUILD_DIR)
 endef
 
 define GTEST_INSTALL_STAGING_CMDS
-	$(INSTALL) -D -m 0755 $(@D)/libgtest.a $(STAGING_DIR)/usr/lib/libgtest.a
-	$(INSTALL) -D -m 0755 $(@D)/libgtest_main.a $(STAGING_DIR)/usr/lib/libgtest_main.a
+	$(INSTALL) -D -m 0755 $(@D)/lib/.libs/libgtest.a $(STAGING_DIR)/usr/lib/libgtest.a
+	$(INSTALL) -D -m 0755 $(@D)/lib/.libs/libgtest_main.a $(STAGING_DIR)/usr/lib/libgtest_main.a
+	$(INSTALL) -D -m 0755 $(@D)/scripts/gtest-config $(STAGING_DIR)/usr/lib/scripts/gtest-config
 	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include/gtest/
 	cp -rp $(@D)/include/gtest/* $(STAGING_DIR)/usr/include/gtest/
 endef
 
-$(eval $(cmake-package))
+$(eval $(autotools-package))
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 gtest: update recipe to use autotools

Quoted 5 lines · Carlos Santos

The previous recipe build gtest using cmake, which prevented compiling gmock (to be submitted in a following patch).

Gmock requires the gtest-config script, which is installed only if gtest is built with autotools.

Because the autotools build script is no longer officially supported
[1] it would be better to use cmake, there is no way to generate the gtest-config script within cmake?

[1]:
gtest-1.7.0/README:
The Autotools build script (configure + make) is no longer officially supportted. You are encouraged to migrate to your own build system or use CMake. If you still need to use Autotools, you can find instructions in the README file from Google Test 1.4.0.

Quoted 40 lines
---
 package/gtest/gtest.mk | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
package/gtest/gtest.mk +4 -13
index 7129c93..e148462 100644
@@ -12,24 +12,16 @@ GTEST_INSTALL_TARGET = NO
 GTEST_LICENSE = BSD-3c
 GTEST_LICENSE_FILES = LICENSE
 
-# While it is possible to build gtest as shared library, using this gtest shared
-# library requires to set some special configure option in the project using
-# gtest.
-# So, force to build gtest as a static library.
-#
-# For further details, refer to the explaination given in the README file from
-# the gtest sources.
-GTEST_CONF_OPTS = -DBUILD_SHARED_LIBS=OFF
-
 define GTEST_EXTRACT_CMDS
        $(UNZIP) $(DL_DIR)/$(GTEST_SOURCE) -d $(BUILD_DIR)
 endef
 
 define GTEST_INSTALL_STAGING_CMDS
-       $(INSTALL) -D -m 0755 $(@D)/libgtest.a $(STAGING_DIR)/usr/lib/libgtest.a
-       $(INSTALL) -D -m 0755 $(@D)/libgtest_main.a $(STAGING_DIR)/usr/lib/libgtest_main.a
+       $(INSTALL) -D -m 0755 $(@D)/lib/.libs/libgtest.a $(STAGING_DIR)/usr/lib/libgtest.a
+       $(INSTALL) -D -m 0755 $(@D)/lib/.libs/libgtest_main.a $(STAGING_DIR)/usr/lib/libgtest_main.a
+       $(INSTALL) -D -m 0755 $(@D)/scripts/gtest-config $(STAGING_DIR)/usr/lib/scripts/gtest-config
        $(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include/gtest/
        cp -rp $(@D)/include/gtest/* $(STAGING_DIR)/usr/include/gtest/
 endef
 
-$(eval $(cmake-package))
+$(eval $(autotools-package))
--
Quoted 1 line

1.8.3.1

This patch apply fine, but it fails to install the gtest package:

defconfig:
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_PACKAGE_GTEST=y

Quoted 1 line
Quoted 1 line
Quoted 1 line

gtest 1.7.0 Installing to staging directory

/usr/bin/install -D -m 0755 /home/tetsuya/buildroot/br/output/build/gtest-1.7.0/lib/.libs/libgtest.a /home/tetsuya/buildroot/br/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/libgtest.a /usr/bin/install: cannot stat ?/home/tetsuya/buildroot/br/output/build/gtest-1.7.0/lib/.libs/libgtest.a?:
No such file or directory
package/pkg-generic.mk:203: recipe for target '/home/tetsuya/buildroot/br/output/build/gtest-1.7.0/.stamp_staging_installed' failed
make: *** [/home/tetsuya/buildroot/br/output/build/gtest-1.7.0/.stamp_staging_installed] Error 1

BR

Signature · 1 line
Fabio Porcedda
#2 lore raw

PATCH 1/1 gtest: update recipe to use autotools

----- Original Message -----

Quoted 10 lines

From: "Fabio Porcedda" <[email protected]>
To: "Carlos Santos" <[email protected]>
Cc: buildroot at buildroot.org
Sent: Sunday, April 19, 2015 8:17:00 AM
Subject: Re: [Buildroot] [PATCH 1/1] gtest: update recipe to use autotools

Quoted 3 lines · Carlos Santos

The previous recipe build gtest using cmake, which prevented compiling gmock (to be submitted in a following patch).

Quoted 7 lines
Quoted 2 lines

Gmock requires the gtest-config script, which is installed only if gtest is built with autotools.

Because the autotools build script is no longer officially supported
[1] it would be better to use cmake, there is no way to generate the gtest-config script within cmake?

OK, I will look for an alternative using CMake.

Quoted 65 lines

[1]:
gtest-1.7.0/README:
The Autotools build script (configure + make) is no longer officially supportted. You are encouraged to migrate to your own build system or use CMake. If you still need to use Autotools, you can find instructions in the README file from Google Test 1.4.0.

Quoted 38 lines
---
 package/gtest/gtest.mk | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
package/gtest/gtest.mk +0 -1
index 7129c93..e148462 100644
@@ -12,24 +12,16 @@ GTEST_INSTALL_TARGET = NO
 GTEST_LICENSE = BSD-3c
 GTEST_LICENSE_FILES = LICENSE
 
-# While it is possible to build gtest as shared library, using this gtest

shared

package/gtest/gtest.mk +0 -10
-# library requires to set some special configure option in the project using
-# gtest.
-# So, force to build gtest as a static library.
-#
-# For further details, refer to the explaination given in the README file from
-# the gtest sources.
-GTEST_CONF_OPTS = -DBUILD_SHARED_LIBS=OFF
-
 define GTEST_EXTRACT_CMDS
        $(UNZIP) $(DL_DIR)/$(GTEST_SOURCE) -d $(BUILD_DIR)
 endef
 
 define GTEST_INSTALL_STAGING_CMDS
-       $(INSTALL) -D -m 0755 $(@D)/libgtest.a $(STAGING_DIR)/usr/lib/libgtest.a
-       $(INSTALL) -D -m 0755 $(@D)/libgtest_main.a

$(STAGING_DIR)/usr/lib/libgtest_main.a
+ $(INSTALL) -D -m 0755 $(@D)/lib/.libs/libgtest.a
$(STAGING_DIR)/usr/lib/libgtest.a
+ $(INSTALL) -D -m 0755 $(@D)/lib/.libs/libgtest_main.a
$(STAGING_DIR)/usr/lib/libgtest_main.a
+ $(INSTALL) -D -m 0755 $(@D)/scripts/gtest-config
$(STAGING_DIR)/usr/lib/scripts/gtest-config

Quoted 8 lines
        $(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include/gtest/
        cp -rp $(@D)/include/gtest/* $(STAGING_DIR)/usr/include/gtest/

endef

-$(eval $(cmake-package))
+$(eval $(autotools-package))
--
1.8.3.1

This patch apply fine, but it fails to install the gtest package:

defconfig:
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_PACKAGE_GTEST=y

Quoted 1 line
Quoted 1 line
Quoted 1 line

gtest 1.7.0 Installing to staging directory

Quoted 12 lines

/usr/bin/install -D -m 0755 /home/tetsuya/buildroot/br/output/build/gtest-1.7.0/lib/.libs/libgtest.a /home/tetsuya/buildroot/br/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/libgtest.a /usr/bin/install: cannot stat ?/home/tetsuya/buildroot/br/output/build/gtest-1.7.0/lib/.libs/libgtest.a?:
No such file or directory
package/pkg-generic.mk:203: recipe for target '/home/tetsuya/buildroot/br/output/build/gtest-1.7.0/.stamp_staging_installed' failed
make: *** [/home/tetsuya/buildroot/br/output/build/gtest-1.7.0/.stamp_staging_installed] Error 1

Ouch! It requires forcing autotools to build the static libraries. I will update the patch accordingly.

Quoted 3 lines

BR
--
Fabio Porcedda

Carlos Santos (Casantos)
DATACOM, P&D

#3 lore raw

PATCH v2 1/1 gtest: update recipe to use autotools

In reply to Fabio Porcedda

The previous recipe build gtest using cmake, which prevented compiling gmock (to be submitted in a following patch).

Gmock requires the gtest-config script, which is installed only if gtest is built with autotools.

Change-Id I71e52d2ccc19160ca936d80b41c127e79f1a7d6a
---
 package/gtest/gtest.mk | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
package/gtest/gtest.mk +8 -13
index 7129c93..1176030 100644
@@ -11,25 +11,20 @@ GTEST_INSTALL_STAGING = YES
 GTEST_INSTALL_TARGET = NO
 GTEST_LICENSE = BSD-3c
 GTEST_LICENSE_FILES = LICENSE
-
-# While it is possible to build gtest as shared library, using this gtest shared
-# library requires to set some special configure option in the project using
-# gtest.
-# So, force to build gtest as a static library.
-#
-# For further details, refer to the explaination given in the README file from
-# the gtest sources.
-GTEST_CONF_OPTS = -DBUILD_SHARED_LIBS=OFF
+GTEST_CONF_OPTS = --enable-static --disable-shared
 
 define GTEST_EXTRACT_CMDS
 	$(UNZIP) $(DL_DIR)/$(GTEST_SOURCE) -d $(BUILD_DIR)
 endef
 
 define GTEST_INSTALL_STAGING_CMDS
-	$(INSTALL) -D -m 0755 $(@D)/libgtest.a $(STAGING_DIR)/usr/lib/libgtest.a
-	$(INSTALL) -D -m 0755 $(@D)/libgtest_main.a $(STAGING_DIR)/usr/lib/libgtest_main.a
+	$(INSTALL) -D -m 0644 $(@D)/lib/.libs/libgtest.a $(STAGING_DIR)/usr/lib/libgtest.a
+	$(INSTALL) -D -m 0644 $(@D)/lib/.libs/libgtest_main.a $(STAGING_DIR)/usr/lib/libgtest_main.a
+	$(INSTALL) -D -m 0644 $(@D)/scripts/gtest-config $(STAGING_DIR)/usr/lib/scripts/gtest-config
 	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include/gtest/
-	cp -rp $(@D)/include/gtest/* $(STAGING_DIR)/usr/include/gtest/
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include/gtest/internal/
+	$(INSTALL) -D -m 0644 $(@D)/include/gtest/*.h* $(STAGING_DIR)/usr/include/gtest/
+	$(INSTALL) -D -m 0644 $(@D)/include/gtest/internal/*.h* $(STAGING_DIR)/usr/include/gtest/internal/
 endef
 
-$(eval $(cmake-package))
+$(eval $(autotools-package))
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v2 1/1 gtest: update recipe to use autotools

Dear Carlos Santos,

Quoted 2 lines · Carlos Santos

-$(eval $(cmake-package))
+$(eval $(autotools-package))

I still don't understand. Fabio quoted the README of gtest, which says:

"""
The Autotools build script (configure + make) is no longer officially supportted. You are encouraged to migrate to your own build system or use CMake.
"""

So why moving from using the supported CMake to the no-longer supported autotools build system would be an improvement?

This really needs more explanations.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

PATCH v2 1/1 gtest: update recipe to use autotools

Quoted 21 lines

From: "Thomas Petazzoni" <[email protected]>
To: "Carlos Santos" <[email protected]>
Cc: buildroot at buildroot.org
Sent: Wednesday, April 22, 2015 5:46:20 PM
Subject: Re: [Buildroot] [PATCH v2 1/1] gtest: update recipe to use autotools

Dear Carlos Santos,

Quoted 2 lines · Carlos Santos

-$(eval $(cmake-package))
+$(eval $(autotools-package))

I still don't understand. Fabio quoted the README of gtest, which says:

"""
The Autotools build script (configure + make) is no longer officially supportted. You are encouraged to migrate to your own build system or use CMake.
"""

Quoted 4 lines

So why moving from using the supported CMake to the no-longer supported autotools build system would be an improvement?

This really needs more explanations.

I agree that using autotools is not the ideal approach but so I don't have a solution to generate the gtest-config script using CMake. I will spend some additional time on this today and submit and alternate patch if possible.

Quoted 5 lines

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

Carlos Santos (Casantos)
DATACOM, P&D

#6 lore raw

PATCH v2 1/1 gtest: update recipe to use autotools

Quoted 21 lines · Carlos Santos
Quoted 21 lines

From: "Thomas Petazzoni" <[email protected]>
To: "Carlos Santos" <[email protected]>
Cc: buildroot at buildroot.org
Sent: Wednesday, April 22, 2015 5:46:20 PM
Subject: Re: [Buildroot] [PATCH v2 1/1] gtest: update recipe to use autotools

Dear Carlos Santos,

Quoted 2 lines · Carlos Santos

-$(eval $(cmake-package))
+$(eval $(autotools-package))

I still don't understand. Fabio quoted the README of gtest, which says:

"""
The Autotools build script (configure + make) is no longer officially supportted. You are encouraged to migrate to your own build system or use CMake.
"""

Quoted 6 lines
Quoted 4 lines

So why moving from using the supported CMake to the no-longer supported autotools build system would be an improvement?

This really needs more explanations.

I agree that using autotools is not the ideal approach but so I don't have a solution to generate the gtest-config script using CMake. I will spend some additional time on this today and submit and alternate patch if possible.

I think it's fairly simple:

# gtest-config is only generated when gtest is built with autotools,
# so generate it manually here.
define GTEST_INSTALL_CONFIG
	sed 's/@PACKAGE_TARNAME@/gtest/;\
		s/@PACKAGE_VERSION@/$(GTEST_VERSION)/;\
		s/..../' \
		$(@D)/scripts/gtest-config.in \
		> $(STAGING_DIR)/usr/bin/gtest-config
endef
GTEST_POST_STAGING_INSTALL_HOOKS += GTEST_INSTALL_CONFIG

Not tested, of course :-)

In particular, I'm not sure if gtest-config gives the correct feedback when
gtest has been installed with cmake.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#7 lore raw

PATCH v2 1/1 gtest: update recipe to use autotools

Arnout, Carlos,

Quoted 10 lines · Arnout Vandecappelle
# gtest-config is only generated when gtest is built with autotools,
# so generate it manually here.
define GTEST_INSTALL_CONFIG
	sed 's/@PACKAGE_TARNAME@/gtest/;\
		s/@PACKAGE_VERSION@/$(GTEST_VERSION)/;\
		s/..../' \
		$(@D)/scripts/gtest-config.in \
		> $(STAGING_DIR)/usr/bin/gtest-config
endef
GTEST_POST_STAGING_INSTALL_HOOKS += GTEST_INSTALL_CONFIG

I've implemented this solution, see commit:

http://git.buildroot.net/buildroot/commit/?id=39186b5f5ac61c72d4b3d3088b7facbfd739abfa

I test that the generated gtest-config returns sane values, but I didn't test with a real program using gtest obviously.

Carlos, can you let us know if that works for your use case?

Thanks a lot,

Thomas Petazzoni

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com