1# SPDX-License-Identifier: Apache-2.0
2
3cmake_minimum_required(VERSION 3.20.0)
4
5set(REMOTE_ZEPHYR_DIR ${CMAKE_CURRENT_BINARY_DIR}/ipm_esp32_appcpu-prefix/src/ipm_esp32_appcpu-build/zephyr)
6
7if("${BOARD}" STREQUAL "esp32_devkitc_wrover/esp32/procpu")
8  set(BOARD_REMOTE "esp32_devkitc_wrover/esp32/appcpu")
9elseif("${BOARD}" STREQUAL "esp32_devkitc_wroom/esp32/procpu")
10  set(BOARD_REMOTE "esp32_devkitc_wroom/esp32/appcpu")
11elseif("${BOARD}" STREQUAL "esp32s3_devkitm/esp32s3/procpu")
12  set(BOARD_REMOTE "esp32s3_devkitm/esp32s3/appcpu")
13else()
14  message(FATAL_ERROR "${BOARD} was not supported for this sample")
15endif()
16
17find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
18project(ipm_esp32)
19
20set_source_files_properties(${REMOTE_ZEPHYR_DIR}/esp32_appcpu_firmware.c PROPERTIES GENERATED TRUE)
21target_sources(app PRIVATE src/main.c ${REMOTE_ZEPHYR_DIR}/esp32_appcpu_firmware.c)
22
23include(ExternalProject)
24
25ExternalProject_Add(
26	ipm_esp32_appcpu
27	SOURCE_DIR ${APPLICATION_SOURCE_DIR}/ipm_esp_appcpu
28	INSTALL_COMMAND ""
29	CMAKE_CACHE_ARGS -DBOARD:STRING=${BOARD_REMOTE}
30	BUILD_BYPRODUCTS "${REMOTE_ZEPHYR_DIR}/${KERNEL_BIN_NAME}"
31	BUILD_ALWAYS True
32)
33
34add_dependencies(app ipm_esp32_appcpu)
35