summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch
blob: 3720833d3e5c95d50d37313096fca697ac987d7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From 1e67c3fe52c6c51c00cf1ebb0bfc30c7a5ef9fdb Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
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 <dev@codyps.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>

---
 Modules/CMakeDetermineSystem.cmake | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake
index dc208c6..e0af4ca 100644
--- a/Modules/CMakeDetermineSystem.cmake
+++ b/Modules/CMakeDetermineSystem.cmake
@@ -81,6 +81,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.