Anas Nashif | 3ae5262 | 2019-04-06 09:08:09 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | |
Anas Nashif | 55cf16a | 2019-01-14 11:21:23 -0500 | [diff] [blame] | 3 | include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/host-tools.cmake) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 4 | |
Martí Bolívar | 53f6aae | 2020-04-29 10:21:20 -0700 | [diff] [blame] | 5 | # dtc is an optional dependency |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 6 | find_program( |
| 7 | DTC |
| 8 | dtc |
| 9 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 10 | |
Sebastian Bøe | 23df708 | 2020-01-27 14:55:18 +0100 | [diff] [blame] | 11 | if(DTC) |
Martí Bolívar | 14d55bc | 2020-04-29 10:21:43 -0700 | [diff] [blame] | 12 | # 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 Rasmussen | 8e8c6cd | 2020-06-12 12:16:00 +0200 | [diff] [blame] | 18 | ERROR_VARIABLE dtc_error_output |
| 19 | RESULT_VARIABLE dtc_status |
Martí Bolívar | 14d55bc | 2020-04-29 10:21:43 -0700 | [diff] [blame] | 20 | ) |
Martí Bolívar | 14d55bc | 2020-04-29 10:21:43 -0700 | [diff] [blame] | 21 | |
Torsten Rasmussen | 8e8c6cd | 2020-06-12 12:16:00 +0200 | [diff] [blame] | 22 | 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ívar | 14d55bc | 2020-04-29 10:21:43 -0700 | [diff] [blame] | 35 | else() |
| 36 | message(WARNING |
Torsten Rasmussen | 8e8c6cd | 2020-06-12 12:16:00 +0200 | [diff] [blame] | 37 | "Could NOT find working dtc: Found dtc (${DTC}), but failed to load with:\n ${dtc_error_output}") |
Martí Bolívar | 14d55bc | 2020-04-29 10:21:43 -0700 | [diff] [blame] | 38 | set(DTC DTC-NOTFOUND) |
| 39 | endif() |
Sebastian Bøe | d5754d3 | 2018-10-18 13:13:03 +0200 | [diff] [blame] | 40 | endif() |
| 41 | |
Sebastian Bøe | f17428a | 2020-01-29 15:39:33 +0100 | [diff] [blame] | 42 | # gperf is an optional dependency |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 43 | find_program( |
| 44 | GPERF |
| 45 | gperf |
| 46 | ) |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 47 | |
Sebastian Bøe | eb8e7b7 | 2017-11-08 19:20:55 +0100 | [diff] [blame] | 48 | # openocd is an optional dependency |
| 49 | find_program( |
| 50 | OPENOCD |
| 51 | openocd |
| 52 | ) |
| 53 | |
Adithya Baglody | 4a693c3 | 2018-06-01 12:07:28 +0530 | [diff] [blame] | 54 | # bossac is an optional dependency |
| 55 | find_program( |
| 56 | BOSSAC |
| 57 | bossac |
| 58 | ) |
| 59 | |
Martí Bolívar | a0382cb | 2020-08-19 09:34:11 -0700 | [diff] [blame] | 60 | # 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) |
| 63 | find_program( |
| 64 | IMGTOOL |
| 65 | imgtool |
| 66 | ) |
| 67 | |
Sebastian Bøe | 12f8f76 | 2017-10-27 15:43:34 +0200 | [diff] [blame] | 68 | # 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. |