blob: 9609f5f7c24582402d1c7ee5b96bf9b416c47bf1 [file] [log] [blame]
William A. Kennington IIIac69b482021-06-02 12:28:27 -07001From e75f76b00cc9c1cfc231c5e731e975552f5dd13e Mon Sep 17 00:00:00 2001
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08002From: Cody P Schafer <dev@codyps.com>
3Date: Thu, 27 Apr 2017 11:35:05 -0400
Brad Bishop08902b02019-08-20 09:16:51 -04004Subject: [PATCH] CMakeDetermineSystem: use oe environment vars to load default
5 toolchain file in sdk
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08006
7Passing the toolchain by:
8
9 - shell aliases does not work if cmake is called by a script
10 - unconditionally by a wrapper script causes cmake to believe it is
11 configuring things when it is not (for example, `cmake --build` breaks).
12
13The OE_CMAKE_TOOLCHAIN_FILE variable is only used as a default if no
14toolchain is explicitly specified.
15
16Setting the CMAKE_TOOLCHAIN_FILE cmake variable is marked as cached
17because '-D' options are cache entries themselves.
18
19Upstream-Status: Inappropriate [oe-core specific]
20Signed-off-by: Cody P Schafer <dev@codyps.com>
21Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Brad Bishop08902b02019-08-20 09:16:51 -040022
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080023---
24 Modules/CMakeDetermineSystem.cmake | 7 +++++++
25 1 file changed, 7 insertions(+)
26
27diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake
William A. Kennington IIIac69b482021-06-02 12:28:27 -070028index bae270de..5bb6bc0d 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080029--- a/Modules/CMakeDetermineSystem.cmake
30+++ b/Modules/CMakeDetermineSystem.cmake
Andrew Geisslerd1e89492021-02-12 15:35:20 -060031@@ -111,6 +111,13 @@ else()
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080032 endif()
33 endif()
34
35+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
36+ if(DEFINED ENV{OE_CMAKE_TOOLCHAIN_FILE})
37+ set(CMAKE_TOOLCHAIN_FILE "$ENV{OE_CMAKE_TOOLCHAIN_FILE}" CACHE FILEPATH "toolchain file")
38+ message(STATUS "Toolchain file defaulted to '${CMAKE_TOOLCHAIN_FILE}'")
39+ endif()
40+endif()
41+
42 # if a toolchain file is used, the user wants to cross compile.
43 # in this case read the toolchain file and keep the CMAKE_HOST_SYSTEM_*
44 # variables around so they can be used in CMakeLists.txt.