[OE-core] cmake: respect ${S} and ${B} patch problem

Miroslav Keš miroslav.kes at gmail.com
Fri Jun 13 16:33:52 UTC 2014


Hi!

I have found a problem related to the patch "respect ${S} and ${B}" on the
cmake.bbclass (commit 43073569cb67d98c11aa71211d77b566b64f9145)

The cmake.bbclass now generates the cmake command using the ${S}
variable as the path where the top most CMakeLists.txt should be found.
This works OK as along as the CMakeLists.txt is in the top level
directory of the package source tree.
But CMake doesn't require the directory tree to be structured that way.
If the top level CMakeLists.txt is in a subdirectory of the package
source tree AND the recipe needs to patch a file which is at a higher
level the OE build is broken.

Example:

${WORKDIR}
    - cmake
        - Modules
            - FindSomePackage.cmake
    - Src
        - CMakeLists.txt  <- top level CMake file

For the cmake.bbclass to work correctly after the patch the S must be
set to the ${WORKDIR}/Src.
But the ${S} is also used as the base directory for patching.
In the example, the patch task creates directory  ${S}/patches (i.e.
${WORKDIR}/Src/patches) and creates symbolic links to all relevant
patches in that directory.
But those patches can only patch files under the ${S} subtree.
The ${WORKDIR}/cmake/Modules/FindSomePackage.cmake becomes invisible for
patches and the patch task ends up with error "No file to patch."

I would propose to return the OECMAKE_SOURCEPATH variable to the
cmake.bbclass, pass it to the cmake command as the "path to the CMake
file", and set its default value to ${S}

Regards

Mira


Signed-off-by: Mira Kes <miroslav.kes at gmail.com>

diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
index c9c15f3..95a1cbf 100644
--- a/meta/classes/cmake.bbclass
+++ b/meta/classes/cmake.bbclass
@@ -65,8 +65,12 @@ EOF
 addtask generate_toolchain_file after do_patch before do_configure
 
 cmake_do_configure() {
-    if [ "${OECMAKE_BUILDPATH}" -o "${OECMAKE_SOURCEPATH}" ]; then
-        bbnote "cmake.bbclass no longer uses OECMAKE_SOURCEPATH and
OECMAKE_BUILDPATH.  The default behaviour is now out-of-tree builds with
B=WORKDIR/build."
+    if [ "${OECMAKE_BUILDPATH}" ]; then
+        bbnote "cmake.bbclass no longer uses OECMAKE_BUILDPATH.  The
default behaviour is now out-of-tree builds with B=WORKDIR/build."
+    fi
+
+    if [ -z "${OECMAKE_SOURCEPATH}" ]; then
+        OECMAKE_SOURCEPATH="${S}"
     fi
 
     if [ "${S}" != "${B}" ]; then
@@ -84,7 +88,7 @@ cmake_do_configure() {
 
     cmake \
       ${OECMAKE_SITEFILE} \
-      ${S} \
+      ${OECMAKE_SOURCEPATH} \
       -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \
       -DCMAKE_INSTALL_BINDIR:PATH=${bindir} \
       -DCMAKE_INSTALL_SBINDIR:PATH=${sbindir} \




More information about the Openembedded-core mailing list