[Buildroot] [git commit] package/gtest: fix gtest.pc/gmock.pc library names for the debug build

Thomas Petazzoni thomas.petazzoni at bootlin.com
Sun Oct 24 13:58:32 UTC 2021


commit: https://git.buildroot.net/buildroot/commit/?id=1afea0b11b140a6d50aff726f2570702cc984a6e
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Fixes:

   - http://autobuild.buildroot.org/results/e1bb8aa1de310f3d27b74ec7d8748d170ad444e2

  >>> libcamera 40f5fddca7f774944a53f58eeaebc4db79c373d8 Building
  [...]
  [114/123] Linking target src/lc-compliance/lc-compliance
  FAILED: src/lc-compliance/lc-compliance
  [...]
  .../host/lib/gcc/arm-buildroot-linux-uclibcgnueabi/10.3.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: cannot find -lgtest

Signed-off-by: Peter Seiderer <ps.report at gmx.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
---
 ...fix-gtest.pc-gmock.pc-library-names-for-t.patch | 62 ++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/package/gtest/0001-pkg-config-fix-gtest.pc-gmock.pc-library-names-for-t.patch b/package/gtest/0001-pkg-config-fix-gtest.pc-gmock.pc-library-names-for-t.patch
new file mode 100644
index 0000000000..c47e8fc8f8
--- /dev/null
+++ b/package/gtest/0001-pkg-config-fix-gtest.pc-gmock.pc-library-names-for-t.patch
@@ -0,0 +1,62 @@
+From cf5a3177159ca832470e7f876cab0a1923fa666f Mon Sep 17 00:00:00 2001
+From: Peter Seiderer <ps.report at gmx.net>
+Date: Fri, 22 Oct 2021 20:17:36 +0200
+Subject: [PATCH] pkg-config: fix gtest.pc/gmock.pc library names for the debug
+ build
+
+In case CMAKE_BUILD_TYPE is set to Debug the gtest library is
+name libgtestd.a but the link command returned from gtest.pc is
+'-lgtest' (without the debug d) and so the linking of dependent
+packages fails (see [1] for a buildroot failure example).
+
+Enhance the gtest.pc ang gmock.pc generation to honour the debug 'd'.
+
+[1] http://lists.busybox.net/pipermail/buildroot/2021-October/626382.html
+
+[Upstream: https://github.com/google/googletest/pull/3625]
+Signed-off-by: Peter Seiderer <ps.report at gmx.net>
+---
+ googlemock/cmake/gmock.pc.in          | 2 +-
+ googletest/cmake/gtest.pc.in          | 2 +-
+ googletest/cmake/internal_utils.cmake | 3 +++
+ 3 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/googlemock/cmake/gmock.pc.in b/googlemock/cmake/gmock.pc.in
+index 23c67b5c..0f469857 100644
+--- a/googlemock/cmake/gmock.pc.in
++++ b/googlemock/cmake/gmock.pc.in
+@@ -6,5 +6,5 @@ Description: GoogleMock (without main() function)
+ Version: @PROJECT_VERSION@
+ URL: https://github.com/google/googletest
+ Requires: gtest = @PROJECT_VERSION@
+-Libs: -L${libdir} -lgmock @CMAKE_THREAD_LIBS_INIT@
++Libs: -L${libdir} -lgmock at DEBUG_POSTFIX@ @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 b4148fae..225bba81 100644
+--- a/googletest/cmake/gtest.pc.in
++++ b/googletest/cmake/gtest.pc.in
+@@ -5,5 +5,5 @@ Name: gtest
+ Description: GoogleTest (without main() function)
+ Version: @PROJECT_VERSION@
+ URL: https://github.com/google/googletest
+-Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@
++Libs: -L${libdir} -lgtest at DEBUG_POSTFIX@ @CMAKE_THREAD_LIBS_INIT@
+ Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@
+diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
+index 58fc9bfb..fd81b825 100644
+--- a/googletest/cmake/internal_utils.cmake
++++ b/googletest/cmake/internal_utils.cmake
+@@ -335,6 +335,9 @@ function(install_project)
+     # Configure and install pkgconfig files.
+     foreach(t ${ARGN})
+       set(configured_pc "${generated_dir}/${t}.pc")
++      if(CMAKE_BUILD_TYPE MATCHES Debug)
++        set(DEBUG_POSTFIX "d")
++      endif()
+       configure_file("${PROJECT_SOURCE_DIR}/cmake/${t}.pc.in"
+         "${configured_pc}" @ONLY)
+       install(FILES "${configured_pc}"
+-- 
+2.33.1
+


More information about the buildroot mailing list