[meta-oe] glog: fix libunwind search in components which depend on glog

Submitted by Martin Jansa on Dec. 5, 2018, 3 p.m. | Patch ID: 156939

Details

Message ID 20181205150052.27047-1-Martin.Jansa@gmail.com
State New
Headers show

Commit Message

Martin Jansa Dec. 5, 2018, 3 p.m.
* libunwind is not found when using find_package(glog) from some
  other recipe, without this change it fails with:

CMake Error at /OE/build/owpb/webos-ports/tmp-glibc/work/tissot-webos-linux/mtp-server/0.0.3+gitrAUTOINC+6159f1a143-r0/recipe-sysroot-native/usr/share/cmake-3.12/Modules/CMakeFindDependencyMacro.cmake:48 (find_package):
  By not providing "FindLibunwind.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "Libunwind", but CMake did not find one.

  Could not find a package configuration file provided by "Libunwind" with
  any of the following names:

    LibunwindConfig.cmake
    libunwind-config.cmake

  Add the installation prefix of "Libunwind" to CMAKE_PREFIX_PATH or set
  "Libunwind_DIR" to a directory containing one of the above files.  If
  "Libunwind" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  /OE/build/owpb/webos-ports/tmp-glibc/work/tissot-webos-linux/mtp-server/0.0.3+gitrAUTOINC+6159f1a143-r0/recipe-sysroot/usr/lib/cmake/glog/glog-config.cmake:31 (find_dependency)
  CMakeLists.txt:17 (find_package)

-- Configuring incomplete, errors occurred!

* this might help others when upgrading to thud which has newer glog:

mtp-server in meta-luneos layer is the only user of glog I could find
in public layers, it was failing to build with 0.3.5 version of glog
(and building fine with 0.3.4 glog which was built with autotools
instead of cmake and provided pkg-config instead of glog-config.cmake)

First part is relatively simple, update CMakeLists.txt to use cmake
machinery instead of pkg-config:

-pkg_check_modules(GLOG REQUIRED libglog)
+find_package(glog 0.3.5 REQUIRED)

and update the use of GLOG_* variables, e.g.:
-  ${GLOG_LIBRARIES}
+  glog::glog

interestingly glog::glog passes the glog library with whole path, in my
case:
  /OE/build/owpb/webos-ports/tmp-glibc/work/tissot-webos-linux/ \
  mtp-server/0.0.3+gitrAUTOINC+6159f1a143-r0/recipe-sysroot/usr/lib/ \
  libglog.so.0.3.5 -lunwind -lunwind-aarch64
instead of just -lglog -unwind -lunwind-aarch64 which would work as
well, because sysroot is configured correctly elsewhere.

I'm not sure if this is really expected behavior of glog::glog or
another bug in glog-config.cmake.

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 .../0002-Find-Libunwind-during-configure.patch    | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch b/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch
index 15cf67fd2e..4d7642a907 100644
--- a/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch
+++ b/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch
@@ -109,12 +109,21 @@  diff -uNr a/CMakeLists.txt b/CMakeLists.txt
  
  install (EXPORT glog-targets NAMESPACE glog:: DESTINATION lib/cmake/glog)
 diff -uNr a/glog-config.cmake.in b/glog-config.cmake.in
---- a/glog-config.cmake.in	2018-11-20 15:49:07.576278417 +0100
-+++ b/glog-config.cmake.in	2018-11-20 15:52:32.330418489 +0100
-@@ -4,4 +4,6 @@
+--- a/glog-config.cmake.in	2018-11-02 14:02:21.784835854 +0100
++++ b/glog-config.cmake.in	2018-11-02 14:03:16.796935594 +0100
+@@ -4,4 +4,15 @@
  
  @gflags_DEPENDENCY@
  
++# Record the state of the CMake module path when this script was
++# called so that we can ensure that we leave it in the same state on
++# exit as it was on entry, but modify it locally.
++set(UNWIND_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
++
++set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
 +find_dependency (Libunwind)
++
++# Restore original module path
++set(CMAKE_MODULE_PATH "${UNWIND_CMAKE_MODULE_PATH}")
 +
  include ("${CMAKE_CURRENT_LIST_DIR}/glog-targets.cmake")

Comments

Martin Jansa Dec. 5, 2018, 4:58 p.m.
This might be actually unnecessary with the:

+list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")

which sneaked in, in the "glog: fix installation path"

On Wed, Dec 5, 2018 at 4:00 PM Martin Jansa <martin.jansa@gmail.com> wrote:

> * libunwind is not found when using find_package(glog) from some
>   other recipe, without this change it fails with:
>
> CMake Error at
> /OE/build/owpb/webos-ports/tmp-glibc/work/tissot-webos-linux/mtp-server/0.0.3+gitrAUTOINC+6159f1a143-r0/recipe-sysroot-native/usr/share/cmake-3.12/Modules/CMakeFindDependencyMacro.cmake:48
> (find_package):
>   By not providing "FindLibunwind.cmake" in CMAKE_MODULE_PATH this project
>   has asked CMake to find a package configuration file provided by
>   "Libunwind", but CMake did not find one.
>
>   Could not find a package configuration file provided by "Libunwind" with
>   any of the following names:
>
>     LibunwindConfig.cmake
>     libunwind-config.cmake
>
>   Add the installation prefix of "Libunwind" to CMAKE_PREFIX_PATH or set
>   "Libunwind_DIR" to a directory containing one of the above files.  If
>   "Libunwind" provides a separate development package or SDK, be sure it
> has
>   been installed.
> Call Stack (most recent call first):
>
> /OE/build/owpb/webos-ports/tmp-glibc/work/tissot-webos-linux/mtp-server/0.0.3+gitrAUTOINC+6159f1a143-r0/recipe-sysroot/usr/lib/cmake/glog/glog-config.cmake:31
> (find_dependency)
>   CMakeLists.txt:17 (find_package)
>
> -- Configuring incomplete, errors occurred!
>
> * this might help others when upgrading to thud which has newer glog:
>
> mtp-server in meta-luneos layer is the only user of glog I could find
> in public layers, it was failing to build with 0.3.5 version of glog
> (and building fine with 0.3.4 glog which was built with autotools
> instead of cmake and provided pkg-config instead of glog-config.cmake)
>
> First part is relatively simple, update CMakeLists.txt to use cmake
> machinery instead of pkg-config:
>
> -pkg_check_modules(GLOG REQUIRED libglog)
> +find_package(glog 0.3.5 REQUIRED)
>
> and update the use of GLOG_* variables, e.g.:
> -  ${GLOG_LIBRARIES}
> +  glog::glog
>
> interestingly glog::glog passes the glog library with whole path, in my
> case:
>   /OE/build/owpb/webos-ports/tmp-glibc/work/tissot-webos-linux/ \
>   mtp-server/0.0.3+gitrAUTOINC+6159f1a143-r0/recipe-sysroot/usr/lib/ \
>   libglog.so.0.3.5 -lunwind -lunwind-aarch64
> instead of just -lglog -unwind -lunwind-aarch64 which would work as
> well, because sysroot is configured correctly elsewhere.
>
> I'm not sure if this is really expected behavior of glog::glog or
> another bug in glog-config.cmake.
>
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  .../0002-Find-Libunwind-during-configure.patch    | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git
> a/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch
> b/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch
> index 15cf67fd2e..4d7642a907 100644
> ---
> a/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch
> +++
> b/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch
> @@ -109,12 +109,21 @@ diff -uNr a/CMakeLists.txt b/CMakeLists.txt
>
>   install (EXPORT glog-targets NAMESPACE glog:: DESTINATION lib/cmake/glog)
>  diff -uNr a/glog-config.cmake.in b/glog-config.cmake.in
> ---- a/glog-config.cmake.in     2018-11-20 15:49:07.576278417 +0100
> -+++ b/glog-config.cmake.in     2018-11-20 15:52:32.330418489 +0100
> -@@ -4,4 +4,6 @@
> +--- a/glog-config.cmake.in     2018-11-02 14:02:21.784835854 +0100
> ++++ b/glog-config.cmake.in     2018-11-02 14:03:16.796935594 +0100
> +@@ -4,4 +4,15 @@
>
>   @gflags_DEPENDENCY@
>
> ++# Record the state of the CMake module path when this script was
> ++# called so that we can ensure that we leave it in the same state on
> ++# exit as it was on entry, but modify it locally.
> ++set(UNWIND_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
> ++
> ++set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
>  +find_dependency (Libunwind)
> ++
> ++# Restore original module path
> ++set(CMAKE_MODULE_PATH "${UNWIND_CMAKE_MODULE_PATH}")
>  +
>   include ("${CMAKE_CURRENT_LIST_DIR}/glog-targets.cmake")
> --
> 2.17.1
>
>
Khem Raj Dec. 5, 2018, 9:33 p.m.
Thanks Martin, I have picked https://patchwork.openembedded.org/patch/156922/
hopefully that is all we need
On Wed, Dec 5, 2018 at 8:58 AM Martin Jansa <martin.jansa@gmail.com> wrote:
>
> This might be actually unnecessary with the:
>
> +list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
>
> which sneaked in, in the "glog: fix installation path"
>
> On Wed, Dec 5, 2018 at 4:00 PM Martin Jansa <martin.jansa@gmail.com> wrote:
>
> > * libunwind is not found when using find_package(glog) from some
> >   other recipe, without this change it fails with:
> >
> > CMake Error at
> > /OE/build/owpb/webos-ports/tmp-glibc/work/tissot-webos-linux/mtp-server/0.0.3+gitrAUTOINC+6159f1a143-r0/recipe-sysroot-native/usr/share/cmake-3.12/Modules/CMakeFindDependencyMacro.cmake:48
> > (find_package):
> >   By not providing "FindLibunwind.cmake" in CMAKE_MODULE_PATH this project
> >   has asked CMake to find a package configuration file provided by
> >   "Libunwind", but CMake did not find one.
> >
> >   Could not find a package configuration file provided by "Libunwind" with
> >   any of the following names:
> >
> >     LibunwindConfig.cmake
> >     libunwind-config.cmake
> >
> >   Add the installation prefix of "Libunwind" to CMAKE_PREFIX_PATH or set
> >   "Libunwind_DIR" to a directory containing one of the above files.  If
> >   "Libunwind" provides a separate development package or SDK, be sure it
> > has
> >   been installed.
> > Call Stack (most recent call first):
> >
> > /OE/build/owpb/webos-ports/tmp-glibc/work/tissot-webos-linux/mtp-server/0.0.3+gitrAUTOINC+6159f1a143-r0/recipe-sysroot/usr/lib/cmake/glog/glog-config.cmake:31
> > (find_dependency)
> >   CMakeLists.txt:17 (find_package)
> >
> > -- Configuring incomplete, errors occurred!
> >
> > * this might help others when upgrading to thud which has newer glog:
> >
> > mtp-server in meta-luneos layer is the only user of glog I could find
> > in public layers, it was failing to build with 0.3.5 version of glog
> > (and building fine with 0.3.4 glog which was built with autotools
> > instead of cmake and provided pkg-config instead of glog-config.cmake)
> >
> > First part is relatively simple, update CMakeLists.txt to use cmake
> > machinery instead of pkg-config:
> >
> > -pkg_check_modules(GLOG REQUIRED libglog)
> > +find_package(glog 0.3.5 REQUIRED)
> >
> > and update the use of GLOG_* variables, e.g.:
> > -  ${GLOG_LIBRARIES}
> > +  glog::glog
> >
> > interestingly glog::glog passes the glog library with whole path, in my
> > case:
> >   /OE/build/owpb/webos-ports/tmp-glibc/work/tissot-webos-linux/ \
> >   mtp-server/0.0.3+gitrAUTOINC+6159f1a143-r0/recipe-sysroot/usr/lib/ \
> >   libglog.so.0.3.5 -lunwind -lunwind-aarch64
> > instead of just -lglog -unwind -lunwind-aarch64 which would work as
> > well, because sysroot is configured correctly elsewhere.
> >
> > I'm not sure if this is really expected behavior of glog::glog or
> > another bug in glog-config.cmake.
> >
> > Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> > ---
> >  .../0002-Find-Libunwind-during-configure.patch    | 15 ++++++++++++---
> >  1 file changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git
> > a/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch
> > b/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch
> > index 15cf67fd2e..4d7642a907 100644
> > ---
> > a/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch
> > +++
> > b/meta-oe/recipes-support/glog/glog/0002-Find-Libunwind-during-configure.patch
> > @@ -109,12 +109,21 @@ diff -uNr a/CMakeLists.txt b/CMakeLists.txt
> >
> >   install (EXPORT glog-targets NAMESPACE glog:: DESTINATION lib/cmake/glog)
> >  diff -uNr a/glog-config.cmake.in b/glog-config.cmake.in
> > ---- a/glog-config.cmake.in     2018-11-20 15:49:07.576278417 +0100
> > -+++ b/glog-config.cmake.in     2018-11-20 15:52:32.330418489 +0100
> > -@@ -4,4 +4,6 @@
> > +--- a/glog-config.cmake.in     2018-11-02 14:02:21.784835854 +0100
> > ++++ b/glog-config.cmake.in     2018-11-02 14:03:16.796935594 +0100
> > +@@ -4,4 +4,15 @@
> >
> >   @gflags_DEPENDENCY@
> >
> > ++# Record the state of the CMake module path when this script was
> > ++# called so that we can ensure that we leave it in the same state on
> > ++# exit as it was on entry, but modify it locally.
> > ++set(UNWIND_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
> > ++
> > ++set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
> >  +find_dependency (Libunwind)
> > ++
> > ++# Restore original module path
> > ++set(CMAKE_MODULE_PATH "${UNWIND_CMAKE_MODULE_PATH}")
> >  +
> >   include ("${CMAKE_CURRENT_LIST_DIR}/glog-targets.cmake")
> > --
> > 2.17.1
> >
> >
> --
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel