1# SPDX-License-Identifier: Apache-2.0
2#
3# Copyright (c) 2022, Nordic Semiconductor ASA
4
5# 'SCA_ROOT' is a prioritized list of directories where SCA tools may
6# be found. It always includes ${ZEPHYR_BASE} at the lowest priority.
7list(APPEND SCA_ROOT ${ZEPHYR_BASE})
8
9zephyr_get(ZEPHYR_SCA_VARIANT)
10
11if(ScaTools_FIND_REQUIRED AND NOT DEFINED ZEPHYR_SCA_VARIANT)
12  message(FATAL_ERROR "ScaTools required but 'ZEPHYR_SCA_VARIANT' is not set. "
13    "Please set 'ZEPHYR_SCA_VARIANT' to desired tool.")
14endif()
15
16if(NOT DEFINED ZEPHYR_SCA_VARIANT)
17  return()
18endif()
19
20foreach(root ${SCA_ROOT})
21  if(EXISTS ${root}/cmake/sca/${ZEPHYR_SCA_VARIANT}/sca.cmake)
22    include(${root}/cmake/sca/${ZEPHYR_SCA_VARIANT}/sca.cmake)
23    return()
24  endif()
25endforeach()
26
27message(FATAL_ERROR "ZEPHYR_SCA_VARIANT set to '${ZEPHYR_SCA_VARIANT}' but no "
28  "implementation for '${ZEPHYR_SCA_VARIANT}' found. SCA_ROOTs searched: ${SCA_ROOT}")
29