blob: cb7bf2e2815ebe0ffa5e4f1afef99152c4607785 [file] [log] [blame]
Anas Nashif3ae52622019-04-06 09:08:09 -04001# SPDX-License-Identifier: Apache-2.0
2
Anas Nashif55cf16a2019-01-14 11:21:23 -05003include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/host-tools.cmake)
Sebastian Bøe12f8f762017-10-27 15:43:34 +02004
Martí Bolívar53f6aae2020-04-29 10:21:20 -07005# dtc is an optional dependency
Sebastian Bøe12f8f762017-10-27 15:43:34 +02006find_program(
7 DTC
8 dtc
9 )
Sebastian Bøe12f8f762017-10-27 15:43:34 +020010
Sebastian Bøe23df7082020-01-27 14:55:18 +010011if(DTC)
Martí Bolívar14d55bc2020-04-29 10:21:43 -070012 # Parse the 'dtc --version' output to find the installed version.
13 set(MIN_DTC_VERSION 1.4.6)
14 execute_process(
15 COMMAND
16 ${DTC} --version
17 OUTPUT_VARIABLE dtc_version_output
Torsten Rasmussen8e8c6cd2020-06-12 12:16:00 +020018 ERROR_VARIABLE dtc_error_output
19 RESULT_VARIABLE dtc_status
Martí Bolívar14d55bc2020-04-29 10:21:43 -070020 )
Martí Bolívar14d55bc2020-04-29 10:21:43 -070021
Torsten Rasmussen8e8c6cd2020-06-12 12:16:00 +020022 if(${dtc_status} EQUAL 0)
23 string(REGEX MATCH "Version: DTC ([0-9]+[.][0-9]+[.][0-9]+).*" out_var ${dtc_version_output})
24
25 # Since it is optional, an outdated version is not an error. If an
26 # outdated version is discovered, print a warning and proceed as if
27 # DTC were not installed.
28 if(${CMAKE_MATCH_1} VERSION_GREATER ${MIN_DTC_VERSION})
29 message(STATUS "Found dtc: ${DTC} (found suitable version \"${CMAKE_MATCH_1}\", minimum required is \"${MIN_DTC_VERSION}\")")
30 else()
31 message(WARNING
32 "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.")
33 set(DTC DTC-NOTFOUND)
34 endif()
Martí Bolívar14d55bc2020-04-29 10:21:43 -070035 else()
36 message(WARNING
Torsten Rasmussen8e8c6cd2020-06-12 12:16:00 +020037 "Could NOT find working dtc: Found dtc (${DTC}), but failed to load with:\n ${dtc_error_output}")
Martí Bolívar14d55bc2020-04-29 10:21:43 -070038 set(DTC DTC-NOTFOUND)
39 endif()
Sebastian Bøed5754d32018-10-18 13:13:03 +020040endif()
41
Sebastian Bøef17428a2020-01-29 15:39:33 +010042# gperf is an optional dependency
Sebastian Bøe12f8f762017-10-27 15:43:34 +020043find_program(
44 GPERF
45 gperf
46 )
Sebastian Bøe12f8f762017-10-27 15:43:34 +020047
Sebastian Bøeeb8e7b72017-11-08 19:20:55 +010048# openocd is an optional dependency
49find_program(
50 OPENOCD
51 openocd
52 )
53
Adithya Baglody4a693c32018-06-01 12:07:28 +053054# bossac is an optional dependency
55find_program(
56 BOSSAC
57 bossac
58 )
59
Martí Bolívara0382cb2020-08-19 09:34:11 -070060# imgtool is an optional dependency (the build may also fall back to
61# scripts/imgtool.py in the mcuboot repository if that's present in
62# some cases)
63find_program(
64 IMGTOOL
65 imgtool
66 )
67
Sebastian Bøe12f8f762017-10-27 15:43:34 +020068# TODO: Should we instead find one qemu binary for each ARCH?
69# TODO: This will probably need to be re-organized when there exists more than one SDK.