diff mbox series

[2/2] package/gerbera: add upstream patch to fix find_program with taglib-config

Message ID 20190610212023.9483-3-joerg.krause@embedded.rocks
State Accepted
Headers show
Series Fix linking gerbera with taglib | expand

Commit Message

Jörg Krause June 10, 2019, 9:20 p.m. UTC
Add an from from upstream to fix linking Gerbera with taglib. The patch
fixes the following issue:

When cross-compiling CMakes `find_program()` will search for binaries on the
host. This is typically correct, e.g. when search for compilers or shells.

When cross-compiling, searching for `taglib-config` using `find_program` should
not find the binary on the host, instead it should find the binary in the sysroot
directory, as the host `taglib-config` will output the wrong host paths
and libs, whereas the sysroot `taglib-config` will output the correct sysroot
paths and libs.

Therefore, use the `CMAKE_FIND_ROOT_PATH_MODE_PROGRAM` variable when
cross-compiling. This variable controls whether the `CMAKE_FIND_ROOT_PATH`
and `CMAKE_SYSROOT` are used by find_program().

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
---
 ...m-taglib-config-when-cross-compiling.patch | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 package/gerbera/0002-Fix-find_program-taglib-config-when-cross-compiling.patch

Comments

Arnout Vandecappelle June 10, 2019, 10:33 p.m. UTC | #1
On 10/06/2019 23:20, Jörg Krause wrote:
[snip]
> ++            if (CMAKE_CROSSCOMPILING)
> ++              set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)

 Again, this is wrong IMO. The executables in the sysroot are not supposed to be
executed on the host.

 What we really should do is to copy those config scripts to some other
location, and add that to the PATH.

 Besides, I think gerbera should be using the .pc file rather than the
taglib-config script.

 Moreover, I think taglib should install a TaglibConfig.cmake file so CMake
packages like gerbera can pick that up directly rather than having to write a
FindTaglib file.

 Regards,
 Arnout

> ++            endif(CMAKE_CROSSCOMPILING)
> +             find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS
> + 		   ${BIN_INSTALL_DIR}
> +             )
> +-- 
> +2.22.0
> +
>
Thomas Petazzoni June 11, 2019, 3:08 p.m. UTC | #2
On Tue, 11 Jun 2019 00:33:31 +0200
Arnout Vandecappelle <arnout@mind.be> wrote:

> > ++            if (CMAKE_CROSSCOMPILING)
> > ++              set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)  
> 
>  Again, this is wrong IMO. The executables in the sysroot are not supposed to be
> executed on the host.
> 
>  What we really should do is to copy those config scripts to some other
> location, and add that to the PATH.

Not so simple: what do you do to differentiate between foo-config
describing foo for the host and foo-config describing foo for the
target ?

Yes, you could install the foo-config in a different directory than
$(HOST_DIR)/bin, but what if some package needs both foo-config for the
host and foo-config for the target, when building its code for the
target ?

Thomas
Peter Korsgaard June 23, 2019, 8:56 p.m. UTC | #3
>>>>> "Jörg" == Jörg Krause <joerg.krause@embedded.rocks> writes:

 > Add an from from upstream to fix linking Gerbera with taglib. The patch
 > fixes the following issue:

 > When cross-compiling CMakes `find_program()` will search for binaries on the
 > host. This is typically correct, e.g. when search for compilers or shells.

 > When cross-compiling, searching for `taglib-config` using `find_program` should
 > not find the binary on the host, instead it should find the binary in the sysroot
 > directory, as the host `taglib-config` will output the wrong host paths
 > and libs, whereas the sysroot `taglib-config` will output the correct sysroot
 > paths and libs.

 > Therefore, use the `CMAKE_FIND_ROOT_PATH_MODE_PROGRAM` variable when
 > cross-compiling. This variable controls whether the `CMAKE_FIND_ROOT_PATH`
 > and `CMAKE_SYSROOT` are used by find_program().

 > Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>

Committed to 2019.02.x and 2019.05.x, thanks.
diff mbox series

Patch

diff --git a/package/gerbera/0002-Fix-find_program-taglib-config-when-cross-compiling.patch b/package/gerbera/0002-Fix-find_program-taglib-config-when-cross-compiling.patch
new file mode 100644
index 0000000000..d5cc908e22
--- /dev/null
+++ b/package/gerbera/0002-Fix-find_program-taglib-config-when-cross-compiling.patch
@@ -0,0 +1,46 @@ 
+From 0f78b883f02651bd15a96a7294e01f94b28c20f8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?J=C3=B6rg=20Krause?= <joerg.krause@embedded.rocks>
+Date: Mon, 13 May 2019 13:42:14 +0200
+Subject: [PATCH] Fix find_program taglib-config when cross-compiling
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When cross-compiling Gerbera CMakes `find_program()` will search for
+binaries on the host. This is typically correct, e.g. when search for
+compilers or shells.
+
+When cross-compiling searching for `taglib-config` should not find the
+binary on the host, instead it should find the binary in the sysroot
+directory, as the host `taglib-config` will output the wrong host paths
+and libs, whereas the sysroot `taglib-config` will output the correct sysroot
+paths and libs.
+
+Therefore, use the `CMAKE_FIND_ROOT_PATH_MODE_PROGRAM` variable when
+cross-compiling. This variable controls whether the `CMAKE_FIND_ROOT_PATH`
+and `CMAKE_SYSROOT` are used by find_program().
+
+Backported from: 0f78b883f02651bd15a96a7294e01f94b28c20f8
+
+Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
+---
+ cmake/FindTaglib.cmake | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/cmake/FindTaglib.cmake b/cmake/FindTaglib.cmake
+index 46a20ff2..7135d766 100644
+--- a/cmake/FindTaglib.cmake
++++ b/cmake/FindTaglib.cmake
+@@ -19,6 +19,9 @@ ELSE()
+ 	endif(NOT TAGLIB_MIN_VERSION)
+ 
+ 	if(NOT WIN32)
++            if (CMAKE_CROSSCOMPILING)
++              set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
++            endif(CMAKE_CROSSCOMPILING)
+             find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS
+ 		   ${BIN_INSTALL_DIR}
+             )
+-- 
+2.22.0
+