cmake: install path variables should be relative to the prefix path
PATCH 1/1 cmake: install path variables should be relative to the prefix path
From: Jack Mitchell <[email protected]>
--- meta/classes/cmake.bbclass | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
meta/classes/cmake.bbclass +9 -9
@@ -108,15 +108,15 @@ cmake_do_configure() { ${OECMAKE_SITEFILE} \ ${OECMAKE_SOURCEPATH} \ -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \ - -DCMAKE_INSTALL_BINDIR:PATH=${bindir} \ - -DCMAKE_INSTALL_SBINDIR:PATH=${sbindir} \ - -DCMAKE_INSTALL_LIBEXECDIR:PATH=${libexecdir} \ - -DCMAKE_INSTALL_SYSCONFDIR:PATH=${sysconfdir} \ - -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${sharedstatedir} \ - -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=${localstatedir} \ - -DCMAKE_INSTALL_LIBDIR:PATH=${libdir} \ - -DCMAKE_INSTALL_INCLUDEDIR:PATH=${includedir} \ - -DCMAKE_INSTALL_DATAROOTDIR:PATH=${datadir} \ + -DCMAKE_INSTALL_BINDIR:PATH=${bindir#${prefix}/} \ + -DCMAKE_INSTALL_SBINDIR:PATH=${sbindir#${prefix}/} \ + -DCMAKE_INSTALL_LIBEXECDIR:PATH=${libexecdir#${prefix}/} \ + -DCMAKE_INSTALL_SYSCONFDIR:PATH=${sysconfdir#${prefix}/} \ + -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${sharedstatedir#${prefix}/} \ + -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=${localstatedir#${prefix}/} \ + -DCMAKE_INSTALL_LIBDIR:PATH=${libdir#${prefix}/} \ + -DCMAKE_INSTALL_INCLUDEDIR:PATH=${includedir#${prefix}/} \ + -DCMAKE_INSTALL_DATAROOTDIR:PATH=${datadir#${prefix}/} \ -DCMAKE_INSTALL_SO_NO_EXE=0 \ -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \ -DCMAKE_VERBOSE_MAKEFILE=1 \
Signature · 1 line
2.9.3
Quoted 26 lines · Jack Mitchell
From: Jack Mitchell <[email protected]>
--- meta/classes/cmake.bbclass | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)meta/classes/cmake.bbclass +2
-9@@ -108,15 +108,15 @@ cmake_do_configure() { ${OECMAKE_SITEFILE} \ ${OECMAKE_SOURCEPATH} \ -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \ - -DCMAKE_INSTALL_BINDIR:PATH=${bindir} \ - -DCMAKE_INSTALL_SBINDIR:PATH=${sbindir} \ - -DCMAKE_INSTALL_LIBEXECDIR:PATH=${libexecdir} \ - -DCMAKE_INSTALL_SYSCONFDIR:PATH=${sysconfdir} \ - -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${sharedstatedir} \ - -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=${localstatedir} \ - -DCMAKE_INSTALL_LIBDIR:PATH=${libdir} \ - -DCMAKE_INSTALL_INCLUDEDIR:PATH=${includedir} \ - -DCMAKE_INSTALL_DATAROOTDIR:PATH=${datadir} \ + -DCMAKE_INSTALL_BINDIR:PATH=${bindir#${prefix}/} \ + -DCMAKE_INSTALL_SBINDIR:PATH=${sbindir#${prefix}/} \
meta/classes/cmake.bbclass cmake_do_configure() { · line 122
Quoted 10 lines
meta/classes/cmake.bbclass +7
-0+ -DCMAKE_INSTALL_LIBEXECDIR:PATH=${libexecdir#${prefix}/} \ + -DCMAKE_INSTALL_SYSCONFDIR:PATH=${sysconfdir#${prefix}/} \ + -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${sharedstatedir#${prefix}/} \ + -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=${localstatedir#${prefix}/} \ + -DCMAKE_INSTALL_LIBDIR:PATH=${libdir#${prefix}/} \ + -DCMAKE_INSTALL_INCLUDEDIR:PATH=${includedir#${prefix}/} \ + -DCMAKE_INSTALL_DATAROOTDIR:PATH=${datadir#${prefix}/} \ -DCMAKE_INSTALL_SO_NO_EXE=0 \ -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \ -DCMAKE_VERBOSE_MAKEFILE=1 \
On second thoughts this isn't doing quite what I expected, how would one remove the prefix from a variable when it's expanded in this manner?
Cheers,
Jack.
Quoted 3 lines · Jack Mitchell
On second thoughts this isn't doing quite what I expected, how would one remove the prefix from a variable when it's expanded in this manner?
You curse cmake for needing install paths to be relative to the prefix?
Ross
Quoted 11 lines · Ross
On 22 August 2016 at 14:23, Jack Mitchell <[email protected] <mailto:[email protected]>> wrote:
On second thoughts this isn't doing quite what I expected, how would one remove the prefix from a variable when it's expanded in this manner?
You curse cmake for needing install paths to be relative to the prefix?
Ross
That was last weeks agenda ;)
Could it be done with some inline python? I'm really not all that clued up on which variables are available when and where to be manipulated. I was thinking something along the lines of
${@d.getVar('bindir').replace(d.getVar('prefix', ''))}
However, this just breaks spectacularly.
Hi,
here's a patch to call CMake with relative paths for some variables. We're using this in production since Nov 2015 without issues. We also reported this upstream and confirmed that CMake expects relative paths.
HTH,
Signature · 7 lines
Clemens Lang • Development Specialist BMW Car IT GmbH • Lise-Meitner-Str. 14 • 89081 Ulm • http://bmw-carit.com ------------------------------------------------------------------------- BMW Car IT GmbH Geschäftsführer: Michael Würtenberger und Alexis Trolin Sitz und Registergericht: München HRB 134810 -------------------------------------------------------------------------
PATCH 1/1 cmake.bbclass: call cmake with a relative path
From: Thomas Witt <[email protected]>
CMake wants a relative path for CMAKE_INSTALL_*DIR, an absolute path breaks cross-compilation. This fact is documented in the following
ticket: https://cmake.org/Bug/view.php?id=14367
$sysconfdir and $localstatedir are not relative to $prefix, so they are still set as absolute paths. With his change ${PROJECT}Targets.cmake that are generated by cmakes "export" function will contain relative paths instead of absolute ones.
--- meta/classes/cmake.bbclass | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
meta/classes/cmake.bbclass +7 -7
@@ -108,15 +108,15 @@ cmake_do_configure() { ${OECMAKE_SITEFILE} \ ${OECMAKE_SOURCEPATH} \ -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \ - -DCMAKE_INSTALL_BINDIR:PATH=${bindir} \ - -DCMAKE_INSTALL_SBINDIR:PATH=${sbindir} \ - -DCMAKE_INSTALL_LIBEXECDIR:PATH=${libexecdir} \ + -DCMAKE_INSTALL_BINDIR:PATH=${@os.path.relpath(d.getVar('bindir', True), d.getVar('prefix', True))} \ + -DCMAKE_INSTALL_SBINDIR:PATH=${@os.path.relpath(d.getVar('sbindir', True), d.getVar('prefix', True))} \ + -DCMAKE_INSTALL_LIBEXECDIR:PATH=${@os.path.relpath(d.getVar('libexecdir', True), d.getVar('prefix', True))} \ -DCMAKE_INSTALL_SYSCONFDIR:PATH=${sysconfdir} \ - -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${sharedstatedir} \ + -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${@os.path.relpath(d.getVar('sharedstatedir', True), d. getVar('prefix', True))} \ -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=${localstatedir} \ - -DCMAKE_INSTALL_LIBDIR:PATH=${libdir} \ - -DCMAKE_INSTALL_INCLUDEDIR:PATH=${includedir} \ - -DCMAKE_INSTALL_DATAROOTDIR:PATH=${datadir} \ + -DCMAKE_INSTALL_LIBDIR:PATH=${@os.path.relpath(d.getVar('libdir', True), d.getVar('prefix', True))} \ + -DCMAKE_INSTALL_INCLUDEDIR:PATH=${@os.path.relpath(d.getVar('includedir', True), d.getVar('prefix', True))} \ + -DCMAKE_INSTALL_DATAROOTDIR:PATH=${@os.path.relpath(d.getVar('datadir', True), d.getVar('prefix', True))} \ -DCMAKE_INSTALL_SO_NO_EXE=0 \ -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \ -DCMAKE_VERBOSE_MAKEFILE=1 \
Signature · 1 line
2.9.3
Re: [PATCH] cmake.bbclass: call cmake with a relative path
Quoted 34 lines · Clemens Lang
From: Thomas Witt <[email protected]>
CMake wants a relative path for CMAKE_INSTALL_*DIR, an absolute path breaks cross-compilation. This fact is documented in the following
ticket: https://cmake.org/Bug/view.php?id=14367$sysconfdir and $localstatedir are not relative to $prefix, so they are still set as absolute paths. With his change ${PROJECT}Targets.cmake that are generated by cmakes "export" function will contain relative paths instead of absolute ones.
Signed-off-by Thomas Witt <[email protected]>Signed-off-by Clemens Lang <[email protected]>--- meta/classes/cmake.bbclass | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)meta/classes/cmake.bbclass +4
-4@@ -108,15 +108,15 @@ cmake_do_configure() { ${OECMAKE_SITEFILE} \ ${OECMAKE_SOURCEPATH} \ -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \ - -DCMAKE_INSTALL_BINDIR:PATH=${bindir} \ - -DCMAKE_INSTALL_SBINDIR:PATH=${sbindir} \ - -DCMAKE_INSTALL_LIBEXECDIR:PATH=${libexecdir} \ + -DCMAKE_INSTALL_BINDIR:PATH=${@os.path.relpath(d.getVar('bindir', True), d.getVar('prefix', True))} \ + -DCMAKE_INSTALL_SBINDIR:PATH=${@os.path.relpath(d.getVar('sbindir', True), d.getVar('prefix', True))} \ + -DCMAKE_INSTALL_LIBEXECDIR:PATH=${@os.path.relpath(d.getVar('libexecdir', True), d.getVar('prefix', True))} \ -DCMAKE_INSTALL_SYSCONFDIR:PATH=${sysconfdir} \ - -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${sharedstatedir} \ + -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${@os.path.relpath(d.getVar('sharedstatedir', True), d. getVar('prefix', True))} \
meta/classes/cmake.bbclass cmake_do_configure() { · line 122
Quoted 10 lines
meta/classes/cmake.bbclass +3
-3-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=${localstatedir} \ - -DCMAKE_INSTALL_LIBDIR:PATH=${libdir} \ - -DCMAKE_INSTALL_INCLUDEDIR:PATH=${includedir} \ - -DCMAKE_INSTALL_DATAROOTDIR:PATH=${datadir} \ + -DCMAKE_INSTALL_LIBDIR:PATH=${@os.path.relpath(d.getVar('libdir', True), d.getVar('prefix', True))} \ + -DCMAKE_INSTALL_INCLUDEDIR:PATH=${@os.path.relpath(d.getVar('includedir', True), d.getVar('prefix', True))} \ + -DCMAKE_INSTALL_DATAROOTDIR:PATH=${@os.path.relpath(d.getVar('datadir', True), d.getVar('prefix', True))} \ -DCMAKE_INSTALL_SO_NO_EXE=0 \ -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \ -DCMAKE_VERBOSE_MAKEFILE=1 \
Thanks. I've just posted another version which uses inline python too; I think your version is nicer though.
Cheers,
Jack.
Re: [PATCH] cmake.bbclass: call cmake with a relative path
In reply to Clemens LangQuoted 9 lines · Clemens Lang
CMake wants a relative path for CMAKE_INSTALL_*DIR, an absolute path breaks cross-compilation. This fact is documented in the following
ticket: https://cmake.org/Bug/view.php?id=14367$sysconfdir and $localstatedir are not relative to $prefix, so they are still set as absolute paths. With his change ${PROJECT}Targets.cmake that are generated by cmakes "export" function will contain relative paths instead of absolute ones.
Seems to work in my testing, but this breaks piglit's bash-completion logic again (resulting in it not installing the file). If you understand cmake then having a quick look at that would be much appreciated. For reference the buildhistory-diff log is:
packages/corei7-64-poky-linux/piglit/piglit-bash-completion: FILELIST:
removed all items "/usr/share/bash-completion/completions/piglit:
Ross
Re: [PATCH] cmake.bbclass: call cmake with a relative path
Hi Ross,
Quoted 7 lines · Ross Burton
Seems to work in my testing, but this breaks piglit's bash-completion logic again (resulting in it not installing the file). If you understand cmake then having a quick look at that would be much appreciated. For reference the buildhistory-diff log is:
packages/corei7-64-poky-linux/piglit/piglit-bash-completion: FILELIST:
removed all items "/usr/share/bash-completion/completions/piglit:
I think this is not related to the patch and currently toggles randomly depending on whether bash-completion’s do_populate_sysroot gets run before piglit’s do_configure. Nothing seems to depend on bash-completion:do_populate_sysroot.
$> bitbake -g piglit
$> grep -c -- '-> "bash-completion\.do_populate_sysroot' task-depends.dot 0
HTH,
Signature · 7 lines
Clemens Lang • Development Specialist BMW Car IT GmbH • Lise-Meitner-Str. 14 • 89081 Ulm • http://bmw-carit.com ------------------------------------------------------------------------- BMW Car IT GmbH Geschäftsführer: Michael Würtenberger und Alexis Trolin Sitz und Registergericht: München HRB 134810 -------------------------------------------------------------------------
Re: [PATCH] cmake.bbclass: call cmake with a relative path
Quoted 17 lines · Clemens Lang
Hi Ross,
Quoted 7 lines · Ross Burton
Seems to work in my testing, but this breaks piglit's bash-completion logic again (resulting in it not installing the file). If you understand cmake then having a quick look at that would be much appreciated. For reference the buildhistory-diff log is:
packages/corei7-64-poky-linux/piglit/piglit-bash-completion: FILELIST:
removed all items "/usr/share/bash-completion/completions/piglit:I think this is not related to the patch and currently toggles randomly depending on whether bash-completion’s
do_populate_sysrootgets run before piglit’sdo_configure. Nothing seems to depend on bash-completion:do_populate_sysroot.
Quoted 5 lines
$> bitbake -g piglit
$> grep -c -- '-> "bash-completion\.do_populate_sysroot'
task-depends.dot
0
This looks likely. The piglit build actually does
find_package(bash-completion NO_MODULE)
to decide whether to install and where.
Arguably this should be explicitly selectable but even then it would also be reasonable for bash-completion.bbclass to ensure that bash-completion.pc and the cmake equivalents are installed in the sysroot...
Jussi
Quoted 16 lines
HTH,
--
Clemens Lang • Development Specialist
BMW Car IT GmbH • Lise-Meitner-Str. 14 • 89081 Ulm • http://bmw-carit.com
-------------------------------------------------------------------------
BMW Car IT GmbH
Geschäftsführer: Michael Würtenberger und Alexis Trolin
Sitz und Registergericht: München HRB 134810
-------------------------------------------------------------------------
--
_______________________________________________
Openembedded-core mailing list [email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Re: [PATCH] cmake.bbclass: call cmake with a relative path
Quoted 4 lines · Jussi Kukkonen
Arguably this should be explicitly selectable but even then it would also be reasonable for bash-completion.bbclass to ensure that bash-completion.pc and the cmake equivalents are installed in the sysroot...
So all this time I'd assumed that bash-completion.bbclass had DEPENDS=bash-completion but it appears not. Surely this is the obvious fix?
Ross