diff options
author | Cody P Schafer <dev@codyps.com> | 2017-05-01 15:29:39 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-07-26 13:16:40 +0100 |
commit | 034ee07ed9b2e88272a010dbbdb685c293c09375 (patch) | |
tree | b59b23d069d83431d101c70fe3180ae644c46fdb /meta/recipes-devtools | |
parent | 24bb79155b69c01d892ccf691fc130b1be8ff7a3 (diff) | |
download | poky-034ee07ed9b2e88272a010dbbdb685c293c09375.tar.gz |
cmake: in SDK use OE env var to set default toolchain
Patch the location in cmake where the toolchain file is loaded
to use the (new) OE_CMAKE_TOOLCHAIN_FILE variable to select a default
toolchain if no toolchain has been specified. The cmake alias is
removed.
The alternatives:
- shell alias fails when cmake is called indirectly (ex: a makefile
managing several projects which calls cmake for some of them)
because aliases are not inherited
- wrapper script that unconditionally adds "-D..." breaks cmake's
build tests and many other things as it causes cmake to believe it
should be configuring things when it should not be. For example,
`cmake -DCMAKE_TOOLCHAIN_FILE=... --build .` does not work (note
that this also breaks people directly using `cmake --build .` with
the current alias).
(From OE-Core rev: da60be3768e7183794d63548166d107dbd0a4973)
Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
3 files changed, 49 insertions, 2 deletions
diff --git a/meta/recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch b/meta/recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch new file mode 100644 index 0000000000..a2332879cf --- /dev/null +++ b/meta/recipes-devtools/cmake/cmake/0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch | |||
@@ -0,0 +1,45 @@ | |||
1 | From a42cfebcd6c684cccf8ad33e5bd5130f7cdba135 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cody P Schafer <dev@codyps.com> | ||
3 | Date: Thu, 27 Apr 2017 11:35:05 -0400 | ||
4 | Subject: [PATCH] CMakeDetermineSystem: use oe environment vars to load default | ||
5 | toolchain file in sdk | ||
6 | |||
7 | Passing 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 | |||
13 | The OE_CMAKE_TOOLCHAIN_FILE variable is only used as a default if no | ||
14 | toolchain is explicitly specified. | ||
15 | |||
16 | Setting the CMAKE_TOOLCHAIN_FILE cmake variable is marked as cached | ||
17 | because '-D' options are cache entries themselves. | ||
18 | |||
19 | Upstream-Status: Inappropriate [oe-core specific] | ||
20 | Signed-off-by: Cody P Schafer <dev@codyps.com> | ||
21 | --- | ||
22 | Modules/CMakeDetermineSystem.cmake | 7 +++++++ | ||
23 | 1 file changed, 7 insertions(+) | ||
24 | |||
25 | diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake | ||
26 | index f34ec5d61..bcac3ef16 100644 | ||
27 | --- a/Modules/CMakeDetermineSystem.cmake | ||
28 | +++ b/Modules/CMakeDetermineSystem.cmake | ||
29 | @@ -74,6 +74,13 @@ else() | ||
30 | endif() | ||
31 | endif() | ||
32 | |||
33 | +if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) | ||
34 | + if(DEFINED ENV{OE_CMAKE_TOOLCHAIN_FILE}) | ||
35 | + set(CMAKE_TOOLCHAIN_FILE "$ENV{OE_CMAKE_TOOLCHAIN_FILE}" CACHE FILEPATH "toolchain file") | ||
36 | + message(STATUS "Toolchain file defaulted to '${CMAKE_TOOLCHAIN_FILE}'") | ||
37 | + endif() | ||
38 | +endif() | ||
39 | + | ||
40 | # if a toolchain file is used, the user wants to cross compile. | ||
41 | # in this case read the toolchain file and keep the CMAKE_HOST_SYSTEM_* | ||
42 | # variables around so they can be used in CMakeLists.txt. | ||
43 | -- | ||
44 | 2.12.2 | ||
45 | |||
diff --git a/meta/recipes-devtools/cmake/cmake/environment.d-cmake.sh b/meta/recipes-devtools/cmake/cmake/environment.d-cmake.sh index 0eb56b66fa..64b6cf3c6a 100644 --- a/meta/recipes-devtools/cmake/cmake/environment.d-cmake.sh +++ b/meta/recipes-devtools/cmake/cmake/environment.d-cmake.sh | |||
@@ -1 +1 @@ | |||
alias cmake="cmake -DCMAKE_TOOLCHAIN_FILE=$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake" | export OE_CMAKE_TOOLCHAIN_FILE="$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake" | ||
diff --git a/meta/recipes-devtools/cmake/cmake_3.11.4.bb b/meta/recipes-devtools/cmake/cmake_3.11.4.bb index 3f8fd7a997..eb055b9757 100644 --- a/meta/recipes-devtools/cmake/cmake_3.11.4.bb +++ b/meta/recipes-devtools/cmake/cmake_3.11.4.bb | |||
@@ -6,7 +6,9 @@ DEPENDS += "curl expat zlib libarchive xz ncurses bzip2" | |||
6 | 6 | ||
7 | SRC_URI_append_class-nativesdk = " \ | 7 | SRC_URI_append_class-nativesdk = " \ |
8 | file://OEToolchainConfig.cmake \ | 8 | file://OEToolchainConfig.cmake \ |
9 | file://environment.d-cmake.sh" | 9 | file://environment.d-cmake.sh \ |
10 | file://0001-CMakeDetermineSystem-use-oe-environment-vars-to-load.patch \ | ||
11 | " | ||
10 | 12 | ||
11 | # Strip ${prefix} from ${docdir}, set result into docdir_stripped | 13 | # Strip ${prefix} from ${docdir}, set result into docdir_stripped |
12 | python () { | 14 | python () { |