From 2b589e939424eb2e235a07ef5a0a00c505b24f6d Mon Sep 17 00:00:00 2001 From: Ronan Le Martret Date: Tue, 10 Jul 2018 14:05:49 +0200 Subject: Fix cmake build with sdk inside a script For the sdk build the cmake config file is source: sysroots/x86_64-aglsdk-linux/environment-setup.d/cmake.sh But use "alias" : alias cmake="cmake ..." Unfortunatly alias is not expand inside a script. using an environnement variable for "CMAKE_TOOLCHAIN_FILE" solve the issue. This Fix is a port of the yocto FIX 139551: https://patchwork.openembedded.org/patch/139551/ Unfortunatly this patch is not include in yocto upstream Bug-AGL: SPEC-1530 Change-Id: Ica80f66cbe976a6ccb1acb7d96b4c4ce4252d4f3 Signed-off-by: Ronan Le Martret --- .../recipes-devtools/cmake/cmake_%.bbappend | 10 +++++ ...ineSystem-use-oe-environment-vars-to-load.patch | 45 ++++++++++++++++++++++ .../cmake/files/environment.d-cmake-agl.sh | 1 + 3 files changed, 56 insertions(+) create mode 100644 meta-agl-profile-core/recipes-devtools/cmake/cmake_%.bbappend create mode 100644 meta-agl-profile-core/recipes-devtools/cmake/files/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch create mode 100644 meta-agl-profile-core/recipes-devtools/cmake/files/environment.d-cmake-agl.sh diff --git a/meta-agl-profile-core/recipes-devtools/cmake/cmake_%.bbappend b/meta-agl-profile-core/recipes-devtools/cmake/cmake_%.bbappend new file mode 100644 index 000000000..22f8163fe --- /dev/null +++ b/meta-agl-profile-core/recipes-devtools/cmake/cmake_%.bbappend @@ -0,0 +1,10 @@ +FILESEXTRAPATHS_append := ":${THISDIR}/files" + +SRC_URI_append_class-nativesdk = " \ + file://0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch \ + file://environment.d-cmake-agl.sh \ +" + +do_install_append_class-nativesdk() { + install -m 644 ${WORKDIR}/environment.d-cmake-agl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/cmake-agl.sh +} diff --git a/meta-agl-profile-core/recipes-devtools/cmake/files/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch b/meta-agl-profile-core/recipes-devtools/cmake/files/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch new file mode 100644 index 000000000..a2332879c --- /dev/null +++ b/meta-agl-profile-core/recipes-devtools/cmake/files/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch @@ -0,0 +1,45 @@ +From a42cfebcd6c684cccf8ad33e5bd5130f7cdba135 Mon Sep 17 00:00:00 2001 +From: Cody P Schafer +Date: Thu, 27 Apr 2017 11:35:05 -0400 +Subject: [PATCH] CMakeDetermineSystem: use oe environment vars to load default + toolchain file in sdk + +Passing the toolchain by: + + - shell aliases does not work if cmake is called by a script + - unconditionally by a wrapper script causes cmake to believe it is + configuring things when it is not (for example, `cmake --build` breaks). + +The OE_CMAKE_TOOLCHAIN_FILE variable is only used as a default if no +toolchain is explicitly specified. + +Setting the CMAKE_TOOLCHAIN_FILE cmake variable is marked as cached +because '-D' options are cache entries themselves. + +Upstream-Status: Inappropriate [oe-core specific] +Signed-off-by: Cody P Schafer +--- + Modules/CMakeDetermineSystem.cmake | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake +index f34ec5d61..bcac3ef16 100644 +--- a/Modules/CMakeDetermineSystem.cmake ++++ b/Modules/CMakeDetermineSystem.cmake +@@ -74,6 +74,13 @@ else() + endif() + endif() + ++if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) ++ if(DEFINED ENV{OE_CMAKE_TOOLCHAIN_FILE}) ++ set(CMAKE_TOOLCHAIN_FILE "$ENV{OE_CMAKE_TOOLCHAIN_FILE}" CACHE FILEPATH "toolchain file") ++ message(STATUS "Toolchain file defaulted to '${CMAKE_TOOLCHAIN_FILE}'") ++ endif() ++endif() ++ + # if a toolchain file is used, the user wants to cross compile. + # in this case read the toolchain file and keep the CMAKE_HOST_SYSTEM_* + # variables around so they can be used in CMakeLists.txt. +-- +2.12.2 + diff --git a/meta-agl-profile-core/recipes-devtools/cmake/files/environment.d-cmake-agl.sh b/meta-agl-profile-core/recipes-devtools/cmake/files/environment.d-cmake-agl.sh new file mode 100644 index 000000000..64b6cf3c6 --- /dev/null +++ b/meta-agl-profile-core/recipes-devtools/cmake/files/environment.d-cmake-agl.sh @@ -0,0 +1 @@ +export OE_CMAKE_TOOLCHAIN_FILE="$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake" -- cgit 1.2.3-korg