]> code.ossystems Code Review - openembedded-core.git/commitdiff
cmake: fix linking in multilib SDKs
authorRoss Burton <ross.burton@intel.com>
Fri, 3 Aug 2018 14:01:12 +0000 (15:01 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 7 Aug 2018 11:12:55 +0000 (12:12 +0100)
CMake, in it's infinite wisdom, when searching for libraries (using
find_library) will look inside the libraries PREFIX/lib, PREFIX/lib32, and
PREFIX/lib64.  In a multilib SDK more than one of these will exist (potentially
all three) and obviously for a given build configuration only one of those is
valid.  This search path is hard-coded deep inside CMake but by setting
CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX we can bypass it and set an explicit
lib<SUFFIX> to use.

Do this by writing ${baselib} into the environment file, and then stripping
"lib" from this to obtain the suffix in the cmake-specific environment script,
which is then read in the CMake toolchain.

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/toolchain-scripts.bbclass
meta/recipes-devtools/cmake/cmake/OEToolchainConfig.cmake
meta/recipes-devtools/cmake/cmake/environment.d-cmake.sh

index 0ff5301530b7f7fad33ec3f73266a9c0cc87ea0c..63b07c802f443e7a4074aa40142b60bc5d0e1ee5 100644 (file)
@@ -51,6 +51,7 @@ toolchain_create_sdk_env_script () {
        echo "export OECORE_NATIVE_SYSROOT=\"$sdkpathnative\"" >> $script
        echo 'export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT"' >> $script
        echo "export OECORE_ACLOCAL_OPTS=\"-I $sdkpathnative/usr/share/aclocal\"" >> $script
+       echo 'export OECORE_BASELIB="${baselib}"' >> $script
        echo 'unset command_not_found_handle' >> $script
 
        toolchain_shared_env_script
index dc8477ea34532158e87d59e130e633c3b64ab4f0..d52c29e5a1cd8d1419a7f820ae9b72e51297599d 100644 (file)
@@ -10,6 +10,8 @@ set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
 
+set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX "$ENV{OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX}")
+
 # Set CMAKE_SYSTEM_PROCESSOR from the sysroot name (assuming processor-distro-os).
 if ($ENV{SDKTARGETSYSROOT} MATCHES "/sysroots/([a-zA-Z0-9_-]+)-.+-.+")
   set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_MATCH_1})
index 64b6cf3c6a30160c1c2fcf640cef7d8627bb05fa..7bdb19fb6ce9c04cfd9c0cbca905590a7fb5ecb2 100644 (file)
@@ -1 +1,2 @@
 export OE_CMAKE_TOOLCHAIN_FILE="$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake"
+export OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX="`echo $OECORE_BASELIB | sed -e s/lib//`"