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."
14  )
15endif()
16
17if(NOT DEFINED ZEPHYR_SCA_VARIANT)
18  return()
19endif()
20
21foreach(root ${SCA_ROOT})
22  if(EXISTS ${root}/cmake/sca/${ZEPHYR_SCA_VARIANT}/sca.cmake)
23    include(${root}/cmake/sca/${ZEPHYR_SCA_VARIANT}/sca.cmake)
24    return()
25  endif()
26endforeach()
27
28message(FATAL_ERROR "ZEPHYR_SCA_VARIANT set to '${ZEPHYR_SCA_VARIANT}' but no "
29                    "implementation for '${ZEPHYR_SCA_VARIANT}' found. "
30                    "SCA_ROOTs searched: ${SCA_ROOT}"
31)
32