1# Copyright (c) 2023-2024 Intel Corporation
2#
3# SPDX-License-Identifier: Apache-2.0
4
5find_program(
6  SIMICS
7  NAMES simics
8  NO_DEFAULT_PATH
9  PATHS ENV SIMICS_PROJECT
10  # Search exactly for the project's autogenerated 'trampoline' script.
11  )
12
13if(SIMICS STREQUAL SIMICS-NOTFOUND)
14  message(WARNING "Simics simulator environment is not found at SIMICS_PROJECT:'${SIMICS_PROJECT}'")
15else()
16  message(STATUS "Found Simics: ${SIMICS}")
17
18  zephyr_get(SIMICS_SCRIPT_PATH SYSBUILD GLOBAL)
19  if(SIMICS_SCRIPT_PATH)
20    set(SIMICS_SCRIPT ${SIMICS_SCRIPT_PATH})
21  else()
22    set(SIMICS_SCRIPT ${BOARD_DIR}/support/${BOARD}.simics)
23  endif()
24
25  get_property(SIMICS_ARGS GLOBAL PROPERTY "BOARD_EMU_ARGS_simics")
26
27  add_custom_target(run_simics
28    COMMAND
29    ${SIMICS}
30    -no-gui
31    --no-win
32    --batch-mode
33    ${SIMICS_SCRIPT}
34    ${SIMICS_ARGS}
35    $ENV{SIMICS_EXTRA_ARGS}
36    -e run
37    WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
38    DEPENDS ${logical_target_for_zephyr_elf}
39    USES_TERMINAL
40    )
41
42endif()
43