diff options
author | Gyorgy Sarvari <skandigraun@gmail.com> | 2025-02-03 13:10:23 +0100 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2025-02-03 11:25:22 -0800 |
commit | 6b1ba4543a2576ef3d83306190a188b6083e6c9e (patch) | |
tree | 16c1301906159002417a94e92c9d1e8d1596e035 | |
parent | 7edd553fbc959e200428d4f58f7d69e336988c88 (diff) | |
download | meta-openembedded-6b1ba4543a2576ef3d83306190a188b6083e6c9e.tar.gz |
capnproto: remove binaries from target-build, add bbclass
When linking to capnproto from another project, cmake fails to
find this package with the following error:
| CMake Error at ${RECIPE_SYSROOT}/usr/lib/cmake/CapnProto/CapnProtoTargets.cmake:176 (message):
| The imported target "CapnProto::capnp_tool" references the file
|
| "${RECIPE_SYSROOT}/usr/bin/capnp"
|
| but this file does not exist. Possible reasons include:
To solve this, this change includes the following:
1. Add a patch that removes the files installed (and exported) in
${bindir} from the target build. The CMake file originally verified
that these files exist when another recipe tried to use it, however
the ${RECIPE_SYSROOT} does not contain the binaries in ${bindir},
so it failed quick in the do_configure step. (This alone is enough
to link against the cross-compiled libraries of capnproto successfully,
but code-generation from capnproto definition fails)
2. Add a new bbclass for capnproto. To cross-compile an application
that uses capnproto, the application needs to be linked against the
cross-compiled version of the libraries, however the native version
of the binaries need to be used to generate C++ code from the
capnproto definitions. This class sets the correct CMake arguments, to
use the capnproto binaries from the native package, instead of looking
for the non-existent cross-compiled binaries. (These variables can
be found in ${libdir}/cmake/CapnProto/CapnProtoConfig.cmake file)
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
3 files changed, 53 insertions, 1 deletions
diff --git a/meta-oe/classes/capnproto.bbclass b/meta-oe/classes/capnproto.bbclass new file mode 100644 index 0000000000..a698f41c95 --- /dev/null +++ b/meta-oe/classes/capnproto.bbclass | |||
@@ -0,0 +1,8 @@ | |||
1 | # Inherit this class in your recipe to compile against | ||
2 | # Cap'N Proto (capnproto) with CMake | ||
3 | |||
4 | DEPENDS:append = " capnproto-native " | ||
5 | DEPENDS:append:class-target = " capnproto " | ||
6 | |||
7 | EXTRA_OECMAKE:append:class-target = " -DCAPNP_EXECUTABLE=${RECIPE_SYSROOT_NATIVE}${bindir}/capnp \ | ||
8 | -DCAPNPC_CXX_EXECUTABLE=${RECIPE_SYSROOT_NATIVE}${bindir}/capnpc-c++ " | ||
diff --git a/meta-oe/recipes-devtools/capnproto/capnproto/0001-Don-t-check-usr-bin-content-from-cmake.patch b/meta-oe/recipes-devtools/capnproto/capnproto/0001-Don-t-check-usr-bin-content-from-cmake.patch new file mode 100644 index 0000000000..6447fadcf9 --- /dev/null +++ b/meta-oe/recipes-devtools/capnproto/capnproto/0001-Don-t-check-usr-bin-content-from-cmake.patch | |||
@@ -0,0 +1,43 @@ | |||
1 | From 43573472a62ff68ba6b1180d6551ef536471a99f Mon Sep 17 00:00:00 2001 | ||
2 | From: Gyorgy Sarvari <skandigraun@gmail.com> | ||
3 | Date: Mon, 3 Feb 2025 11:52:01 +0100 | ||
4 | Subject: [PATCH] Don't install files in bindir | ||
5 | |||
6 | This patch prevents the generated binary executables from being | ||
7 | installed into the /usr/bin folder. | ||
8 | |||
9 | By default, cmake installs these binaries into the /usr/bin folder, | ||
10 | (e.g. binaries used to generate C++ source from the capnproto definition | ||
11 | files) however with Yocto, when using the cross-compiled version of this | ||
12 | application, the /usr/bin folder is not populated in the sysroot. | ||
13 | The generated cmake file however tries to verify that these binaries | ||
14 | exist, and since it cannot find them, it fails the build. | ||
15 | |||
16 | But even in case these files would exist, they are not usable on the build | ||
17 | machine, as these are cross-compiled for the target machine. When another | ||
18 | recipe it built against the capnproto cmake package, the application can | ||
19 | link against the cross-compiled libraries as expected, but for code | ||
20 | generation the capnproto-native package's binaries need to be used. | ||
21 | |||
22 | This patch is only applicable on the cross-compiled version of capnproto. | ||
23 | |||
24 | Upstream-Status: Inappropriate [oe specific: see above message] | ||
25 | |||
26 | Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com> | ||
27 | --- | ||
28 | c++/src/capnp/CMakeLists.txt | 2 -- | ||
29 | 1 file changed, 2 deletions(-) | ||
30 | |||
31 | diff --git a/c++/src/capnp/CMakeLists.txt b/c++/src/capnp/CMakeLists.txt | ||
32 | index 9980fde6..101a7091 100644 | ||
33 | --- a/src/capnp/CMakeLists.txt | ||
34 | +++ b/src/capnp/CMakeLists.txt | ||
35 | @@ -210,8 +210,6 @@ if(NOT CAPNP_LITE) | ||
36 | target_link_libraries(capnpc_capnp capnp kj) | ||
37 | set_target_properties(capnpc_capnp PROPERTIES OUTPUT_NAME capnpc-capnp) | ||
38 | |||
39 | - install(TARGETS capnp_tool capnpc_cpp capnpc_capnp ${INSTALL_TARGETS_DEFAULT_ARGS}) | ||
40 | - | ||
41 | if(WIN32) | ||
42 | # On Windows platforms symlinks are not guaranteed to support. Also different version of CMake handle create_symlink in a different way. | ||
43 | # The most portable way in this case just copy the file. | ||
diff --git a/meta-oe/recipes-devtools/capnproto/capnproto_1.0.2.bb b/meta-oe/recipes-devtools/capnproto/capnproto_1.0.2.bb index daeeb975f2..6136ff20fb 100644 --- a/meta-oe/recipes-devtools/capnproto/capnproto_1.0.2.bb +++ b/meta-oe/recipes-devtools/capnproto/capnproto_1.0.2.bb | |||
@@ -5,7 +5,8 @@ SECTION = "console/tools" | |||
5 | LICENSE = "MIT" | 5 | LICENSE = "MIT" |
6 | LIC_FILES_CHKSUM = "file://../LICENSE;md5=a05663ae6cca874123bf667a60dca8c9" | 6 | LIC_FILES_CHKSUM = "file://../LICENSE;md5=a05663ae6cca874123bf667a60dca8c9" |
7 | 7 | ||
8 | SRC_URI = "git://github.com/sandstorm-io/capnproto.git;branch=release-${PV};protocol=https" | 8 | SRC_URI = "git://github.com/sandstorm-io/capnproto.git;branch=release-${PV};protocol=https \ |
9 | file://0001-Don-t-check-usr-bin-content-from-cmake.patch" | ||
9 | SRCREV = "1a0e12c0a3ba1f0dbbad45ddfef555166e0a14fc" | 10 | SRCREV = "1a0e12c0a3ba1f0dbbad45ddfef555166e0a14fc" |
10 | 11 | ||
11 | S = "${WORKDIR}/git/c++" | 12 | S = "${WORKDIR}/git/c++" |