2019-04-06 21:08:09 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2019-01-15 00:21:23 +08:00
|
|
|
include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/host-tools.cmake)
|
2017-10-27 21:43:34 +08:00
|
|
|
|
2018-11-12 22:23:51 +08:00
|
|
|
# west is optional
|
|
|
|
find_program(
|
|
|
|
WEST
|
|
|
|
west
|
|
|
|
)
|
|
|
|
if(${WEST} STREQUAL WEST-NOTFOUND)
|
|
|
|
unset(WEST)
|
2019-03-12 04:42:31 +08:00
|
|
|
else()
|
|
|
|
# If west is found, make sure its version matches the minimum
|
|
|
|
# required one.
|
2019-07-23 01:00:59 +08:00
|
|
|
set(MIN_WEST_VERSION 0.6.0)
|
2019-03-12 04:42:31 +08:00
|
|
|
execute_process(
|
|
|
|
COMMAND
|
2019-11-05 23:54:20 +08:00
|
|
|
${PYTHON_EXECUTABLE}
|
|
|
|
-c
|
|
|
|
"import west.version; print(west.version.__version__, end='')"
|
|
|
|
OUTPUT_VARIABLE west_version
|
|
|
|
RESULT_VARIABLE west_version_output_result
|
2019-03-12 04:42:31 +08:00
|
|
|
)
|
|
|
|
|
2019-11-05 23:54:20 +08:00
|
|
|
if(west_version_output_result)
|
|
|
|
message(FATAL_ERROR "Unable to import west.version from '${PYTHON_EXECUTABLE}'")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${west_version} VERSION_LESS ${MIN_WEST_VERSION})
|
|
|
|
message(FATAL_ERROR "The detected west version is unsupported.\n\
|
2019-03-12 04:42:31 +08:00
|
|
|
The version was found to be ${west_version}:\n\
|
|
|
|
${item}\n\
|
|
|
|
But the minimum supported version is ${MIN_WEST_VERSION}\n\
|
2019-11-05 23:54:20 +08:00
|
|
|
Please upgrade with:\n\
|
|
|
|
pip3 install --upgrade west")
|
|
|
|
endif()
|
2019-03-12 04:42:31 +08:00
|
|
|
# Just output information for a single version. This will still work
|
|
|
|
# even after output is one line.
|
|
|
|
message(STATUS "Found west: ${WEST} (found suitable version \"${west_version}\", minimum required is \"${MIN_WEST_VERSION}\")")
|
2019-06-12 07:57:37 +08:00
|
|
|
|
2020-02-10 22:07:51 +08:00
|
|
|
if (${west_version} VERSION_GREATER_EQUAL "0.7.1")
|
2019-06-12 07:57:37 +08:00
|
|
|
execute_process(
|
|
|
|
COMMAND ${WEST} topdir
|
|
|
|
OUTPUT_VARIABLE WEST_TOPDIR
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
endif()
|
2018-11-12 22:23:51 +08:00
|
|
|
endif()
|
|
|
|
|
2020-01-27 21:55:18 +08:00
|
|
|
# dtc is an optional dependency. Search for it on PATH and in
|
2017-10-27 21:43:34 +08:00
|
|
|
# TOOLCHAIN_HOME. Usually DTC will be provided by an SDK, but for
|
2018-08-03 23:11:23 +08:00
|
|
|
# SDK-less projects like gnuarmemb, it is up to the user to install
|
2017-10-27 21:43:34 +08:00
|
|
|
# dtc.
|
|
|
|
find_program(
|
|
|
|
DTC
|
|
|
|
dtc
|
|
|
|
)
|
|
|
|
|
2020-01-27 21:55:18 +08:00
|
|
|
if(DTC)
|
2018-10-18 19:13:03 +08:00
|
|
|
# Parse the 'dtc --version' and make sure it is at least MIN_DTC_VERSION
|
|
|
|
set(MIN_DTC_VERSION 1.4.6)
|
|
|
|
execute_process(
|
|
|
|
COMMAND
|
|
|
|
${DTC} --version
|
|
|
|
OUTPUT_VARIABLE dtc_version_output
|
|
|
|
)
|
|
|
|
string(REGEX MATCH "Version: DTC ([0-9]+\.[0-9]+.[0-9]+).*" out_var ${dtc_version_output})
|
|
|
|
if(${CMAKE_MATCH_1} VERSION_LESS ${MIN_DTC_VERSION})
|
|
|
|
assert(0 "The detected dtc version is unsupported. \n\
|
2018-12-19 17:40:57 +08:00
|
|
|
The version was found to be ${CMAKE_MATCH_1} \n\
|
|
|
|
But the minimum supported version is ${MIN_DTC_VERSION} \n\
|
2019-02-04 06:29:46 +08:00
|
|
|
See https://docs.zephyrproject.org/latest/getting_started/ \n\
|
2018-12-19 17:40:57 +08:00
|
|
|
for how to use the SDK's dtc alongside a custom toolchain."
|
|
|
|
)
|
2018-10-18 19:13:03 +08:00
|
|
|
endif()
|
2020-01-27 21:55:18 +08:00
|
|
|
endif(DTC)
|
2018-10-18 19:13:03 +08:00
|
|
|
|
2020-01-29 22:39:33 +08:00
|
|
|
# gperf is an optional dependency
|
2017-10-27 21:43:34 +08:00
|
|
|
find_program(
|
|
|
|
GPERF
|
|
|
|
gperf
|
|
|
|
)
|
|
|
|
|
2017-11-09 02:20:55 +08:00
|
|
|
# openocd is an optional dependency
|
|
|
|
find_program(
|
|
|
|
OPENOCD
|
|
|
|
openocd
|
|
|
|
)
|
|
|
|
|
2018-06-01 14:37:28 +08:00
|
|
|
# bossac is an optional dependency
|
|
|
|
find_program(
|
|
|
|
BOSSAC
|
|
|
|
bossac
|
|
|
|
)
|
|
|
|
|
2017-10-27 21:43:34 +08:00
|
|
|
# TODO: Should we instead find one qemu binary for each ARCH?
|
|
|
|
# TODO: This will probably need to be re-organized when there exists more than one SDK.
|