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 13cmake_minimum_required(VERSION 3.20.0) 14 15if(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 ) 19endif() 20 21if("${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() 26endif() 27 28set(ZEPHYR_BASE ${CMAKE_CURRENT_LIST_DIR}/../) 29list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/modules) 30find_package(HostTools) 31 32if("${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}") 37else() 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() 46endif() 47