Torsten Rasmussen | 8d2998d | 2022-08-29 23:40:10 +0200 | [diff] [blame] | 1 | # The purpose of this file is to verify that required variables has been |
| 2 | # defined for proper toolchain use. |
| 3 | # |
| 4 | # This file is intended to be executed in script mode so that it can be used in |
| 5 | # other tools, such as twister / python scripts. |
| 6 | # |
| 7 | # When invoked as a script with -P: |
| 8 | # cmake [options] -P verify-toolchain.cmake |
| 9 | # |
| 10 | # it takes the following arguments: |
| 11 | # FORMAT=json: Print the output as a json formatted string, useful for Python |
| 12 | |
| 13 | cmake_minimum_required(VERSION 3.20.0) |
| 14 | |
| 15 | if(NOT CMAKE_SCRIPT_MODE_FILE) |
| 16 | message(FATAL_ERROR "verify-toolchain.cmake is a script and must be invoked " |
| 17 | "as:\n 'cmake ... -P verify-toolchain.cmake'\n" |
| 18 | ) |
| 19 | endif() |
| 20 | |
| 21 | if("${FORMAT}" STREQUAL "json") |
| 22 | # If executing in script mode and output format is specified, then silence |
| 23 | # all other messages as only the specified output should be printed. |
| 24 | function(message) |
| 25 | endfunction() |
| 26 | endif() |
| 27 | |
| 28 | set(ZEPHYR_BASE ${CMAKE_CURRENT_LIST_DIR}/../) |
| 29 | list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/modules) |
| 30 | find_package(HostTools) |
| 31 | |
| 32 | if("${FORMAT}" STREQUAL "json") |
| 33 | set(json "{\"ZEPHYR_TOOLCHAIN_VARIANT\" : \"${ZEPHYR_TOOLCHAIN_VARIANT}\", ") |
| 34 | string(APPEND json "\"SDK_VERSION\": \"${SDK_VERSION}\", ") |
| 35 | string(APPEND json "\"ZEPHYR_SDK_INSTALL_DIR\" : \"${ZEPHYR_SDK_INSTALL_DIR}\"}") |
| 36 | _message("${json}") |
| 37 | else() |
| 38 | message(STATUS "ZEPHYR_TOOLCHAIN_VARIANT: ${ZEPHYR_TOOLCHAIN_VARIANT}") |
| 39 | if(DEFINED SDK_VERSION) |
| 40 | message(STATUS "SDK_VERSION: ${SDK_VERSION}") |
| 41 | endif() |
| 42 | |
| 43 | if(DEFINED ZEPHYR_SDK_INSTALL_DIR) |
| 44 | message(STATUS "ZEPHYR_SDK_INSTALL_DIR : ${ZEPHYR_SDK_INSTALL_DIR}") |
| 45 | endif() |
| 46 | endif() |