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
|
|
|
|
2020-04-30 01:21:20 +08:00
|
|
|
# dtc is an optional dependency
|
2017-10-27 21:43:34 +08:00
|
|
|
find_program(
|
|
|
|
DTC
|
|
|
|
dtc
|
|
|
|
)
|
|
|
|
|
2020-01-27 21:55:18 +08:00
|
|
|
if(DTC)
|
2020-04-30 01:21:43 +08:00
|
|
|
# Parse the 'dtc --version' output to find the installed version.
|
|
|
|
set(MIN_DTC_VERSION 1.4.6)
|
|
|
|
execute_process(
|
|
|
|
COMMAND
|
|
|
|
${DTC} --version
|
|
|
|
OUTPUT_VARIABLE dtc_version_output
|
2020-06-12 18:16:00 +08:00
|
|
|
ERROR_VARIABLE dtc_error_output
|
|
|
|
RESULT_VARIABLE dtc_status
|
2020-04-30 01:21:43 +08:00
|
|
|
)
|
|
|
|
|
2020-06-12 18:16:00 +08:00
|
|
|
if(${dtc_status} EQUAL 0)
|
|
|
|
string(REGEX MATCH "Version: DTC ([0-9]+[.][0-9]+[.][0-9]+).*" out_var ${dtc_version_output})
|
|
|
|
|
|
|
|
# Since it is optional, an outdated version is not an error. If an
|
|
|
|
# outdated version is discovered, print a warning and proceed as if
|
|
|
|
# DTC were not installed.
|
|
|
|
if(${CMAKE_MATCH_1} VERSION_GREATER ${MIN_DTC_VERSION})
|
|
|
|
message(STATUS "Found dtc: ${DTC} (found suitable version \"${CMAKE_MATCH_1}\", minimum required is \"${MIN_DTC_VERSION}\")")
|
|
|
|
else()
|
|
|
|
message(WARNING
|
|
|
|
"Could NOT find dtc: Found unsuitable version \"${CMAKE_MATCH_1}\", but required is at least \"${MIN_DTC_VERSION}\" (found ${DTC}). Optional devicetree error checking with dtc will not be performed.")
|
|
|
|
set(DTC DTC-NOTFOUND)
|
|
|
|
endif()
|
2020-04-30 01:21:43 +08:00
|
|
|
else()
|
|
|
|
message(WARNING
|
2020-06-12 18:16:00 +08:00
|
|
|
"Could NOT find working dtc: Found dtc (${DTC}), but failed to load with:\n ${dtc_error_output}")
|
2020-04-30 01:21:43 +08:00
|
|
|
set(DTC DTC-NOTFOUND)
|
|
|
|
endif()
|
2018-10-18 19:13:03 +08:00
|
|
|
endif()
|
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
2020-08-20 00:34:11 +08:00
|
|
|
# imgtool is an optional dependency (the build may also fall back to
|
|
|
|
# scripts/imgtool.py in the mcuboot repository if that's present in
|
|
|
|
# some cases)
|
|
|
|
find_program(
|
|
|
|
IMGTOOL
|
|
|
|
imgtool
|
|
|
|
)
|
|
|
|
|
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.
|