[OE-core] [PATCH] cmake.bbclass: Exclude native sysroot from CMAKE_FIND_ROOT_PATH

Khem Raj raj.khem at gmail.com
Sat Nov 5 16:39:36 UTC 2016



On 11/1/16 11:33 AM, Khem Raj wrote:
> On Nov 1, 2016 11:28 AM, "Andre McCurdy" <armccurdy at gmail.com
> <mailto:armccurdy at gmail.com>> wrote:
>>
>> On Sat, Oct 29, 2016 at 1:47 AM, Khem Raj <raj.khem at gmail.com
> <mailto:raj.khem at gmail.com>> wrote:
>> > This has been cause of issue where we were getting both usr/include
>> > dirs ( from target as well as native sysroot) added to compiler
>> > flags.
>> >
>> > CXX_INCLUDES in final flags.cmake would include
>> > -I<target-sysroot>/usr/include -I<native-sysroot>/usr/include
>> > most of the time it would work since headers are mostly
>> > common but netflix package failed to compile since one of
>> > the headers was including curl headers which it could not
>> > find in target sysroot and it went to next include path
>> > and found it in native sysroot which is not what we want
>> > when doing cross compile.
>> >
>> > As per https://cmake.org/Wiki/CMake_Cross_Compiling
>> > never search for programs in target sysroot but search
>> > for packages,libs,includes only.
>> >
>> > Signed-off-by: Khem Raj <raj.khem at gmail.com <mailto:raj.khem at gmail.com>>
>> > ---
>> >  meta/classes/cmake.bbclass | 3 ++-
>> >  1 file changed, 2 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
>> > index 3e762de..3e8df37 100644
>> > --- a/meta/classes/cmake.bbclass
>> > +++ b/meta/classes/cmake.bbclass
>> > @@ -25,6 +25,7 @@ OECMAKE_PERLNATIVE_DIR ??= ""
>> >  OECMAKE_EXTRA_ROOT_PATH ?= ""
>> >
>> >  OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "ONLY"
>> > +OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM_class-target = "NEVER"
>>
>> Using the _class-target over-ride looks odd. Perhaps making "NEVER"
>> the default and adding over-rides for the classes which need "ONLY"
>> (if there are any?) would make this clearer?
>>
> 
> Yeah I plan to rework this a bit in that direction

thinking a bit more about this problem. It doesn't seem to be solvable
with the current limitations that we have for cross compiling with cmake
in OE environment.

What we want is

1. When compiling target packages that we should be able to use binaries and
programs from native sysroot but not libraries, packages and includes

This is not possible since for this we have to add both native and target
sysroots to CMAKE_FIND_ROOT_PATH, but there is no fine grained selection
method for expressive the requirement 1 above. We only have options
ONLY - Look for files only in paths specified in CMAKE_FIND_ROOT_PATH
BOTH - Along with above also look into build hosts root dir
NEVER - Only look for files in build hosts root dir

so we can not set CMAKE_FIND_ROOT_PATH dynamically according to MODE variables
and hence the problem persists.

cmake does not cater to OE usecase where we have native sysroot along with
host to complement native packages. It only assumes there is build host and
the target sysroot.

>> >  OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM_class-native = "BOTH"
>> >
>> >  EXTRA_OECMAKE_append = " ${PACKAGECONFIG_CONFARGS}"
>> > @@ -60,7 +61,7 @@ set( CMAKE_CXX_LINK_FLAGS "${OECMAKE_CXX_LINK_FLAGS}"
> CACHE STRING "LDFLAGS" )
>> >
>> >  # only search in the paths provided so cmake doesnt pick
>> >  # up libraries and tools from the native build machine
>> > -set( CMAKE_FIND_ROOT_PATH ${STAGING_DIR_HOST} ${STAGING_DIR_NATIVE}
> ${CROSS_DIR} ${OECMAKE_PERLNATIVE_DIR} ${OECMAKE_EXTRA_ROOT_PATH}
> ${EXTERNAL_TOOLCHAIN})
>> > +set( CMAKE_FIND_ROOT_PATH ${STAGING_DIR_HOST} ${CROSS_DIR}
> ${OECMAKE_PERLNATIVE_DIR} ${OECMAKE_EXTRA_ROOT_PATH} ${EXTERNAL_TOOLCHAIN})
>> >  set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
>> >  set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
> ${OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM} )
>> >  set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
>> > --
>> > 2.10.1
>> >
>> > --
>> > _______________________________________________
>> > Openembedded-core mailing list
>> > Openembedded-core at lists.openembedded.org
> <mailto:Openembedded-core at lists.openembedded.org>
>> > http://lists.openembedded.org/mailman/listinfo/openembedded-core
> 



More information about the Openembedded-core mailing list