Hey, I would like to propose the appended patch for Poky's CMake toolchain to 
allow its usage inside a Yocto SDK for building libraries and applications 
using an external (meaning as in "different to the native SDK dir") install 
directory.
I hope that I use the correct mailing list and patch format. (It's my first 
patch to Yocto) Please tell me if this mail is better suited for a different 
mailing list.

Cheers,
Andreas
>From b09bc09c13d1ec9334bdc8a2c148436f1f363b71 Mon Sep 17 00:00:00 2001
From: Andreas Cord-Landwehr <cordlandw...@kde.org>
Date: Mon, 26 Dec 2016 13:43:02 +0100
Subject: [PATCH] Provide additional OECORE_EXTRA_SYSROOT variable

When compiling against a Yocto generated SDK and using an install folder
outside of the SDK's folder, CMake must be configure by using the
respective CMAKE_FIND_ROOT_PATH. This CMake cache variable is set
in the toolchain file and hence can only be configured via environment
variables; unless one wants to modify a project's CMake files.

This patch adds an additional environment variable OECORE_EXTRA_SYSROOT
to specify such an additional sysroot location that can optionally
be used when building against a Yocto SDK using this toolchain file.

Signed-off-by: Andreas Cord-Landwehr <cordlandw...@kde.org>
---
 meta/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake b/meta/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake
index 6518408c70..1927e0bdb4 100644
--- a/meta/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake
+++ b/meta/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake
@@ -4,7 +4,10 @@ set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS}  CACHE STRING "" FORCE )
 set( CMAKE ASM_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "" FORCE )
 set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE )
 
-set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT} )
+# Re-root CMake search tree to sysroot locations given by environment variables OECORE_TARGET_SYSROOT and
+# OECORE_NATIVE_SYSROOT. For additional locations, e.g. a cross-building install directory, use
+# the OECORE_EXTRA_SYSROOT variable.
+set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT} $ENV{OECORE_EXTRA_SYSROOT} )
 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
-- 
2.11.0

-- 
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to