2020-09-23 06:55:55 +01:00
|
|
|
# Top-level cmake file for building MicroPython on ESP32.
|
|
|
|
|
2021-04-22 01:26:52 +01:00
|
|
|
cmake_minimum_required(VERSION 3.12)
|
2020-09-23 06:55:55 +01:00
|
|
|
|
|
|
|
# Set the location of this port's directory.
|
|
|
|
set(MICROPY_PORT_DIR ${CMAKE_SOURCE_DIR})
|
|
|
|
|
|
|
|
# Set the board if it's not already set.
|
|
|
|
if(NOT MICROPY_BOARD)
|
|
|
|
set(MICROPY_BOARD GENERIC)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Set the board directory and check that it exists.
|
|
|
|
if(NOT MICROPY_BOARD_DIR)
|
|
|
|
set(MICROPY_BOARD_DIR ${MICROPY_PORT_DIR}/boards/${MICROPY_BOARD})
|
|
|
|
endif()
|
|
|
|
if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
|
|
|
|
message(FATAL_ERROR "Invalid MICROPY_BOARD specified: ${MICROPY_BOARD}")
|
|
|
|
endif()
|
|
|
|
|
2021-05-13 05:10:06 +01:00
|
|
|
# Include main IDF cmake file.
|
|
|
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
|
|
|
|
2020-09-23 06:55:55 +01:00
|
|
|
# Define the output sdkconfig so it goes in the build directory.
|
|
|
|
set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig)
|
|
|
|
|
2022-04-03 17:22:17 +01:00
|
|
|
# Save the manifest file set from the cmake command line.
|
|
|
|
set(MICROPY_USER_FROZEN_MANIFEST ${MICROPY_FROZEN_MANIFEST})
|
|
|
|
|
2020-09-23 06:55:55 +01:00
|
|
|
# Include board config; this is expected to set SDKCONFIG_DEFAULTS (among other options).
|
|
|
|
include(${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
|
|
|
|
|
2022-04-03 17:22:17 +01:00
|
|
|
# Set the frozen manifest file. Note if MICROPY_FROZEN_MANIFEST is set from the cmake
|
|
|
|
# command line, then it will override the default and any manifest set by the board.
|
|
|
|
if (MICROPY_USER_FROZEN_MANIFEST)
|
|
|
|
set(MICROPY_FROZEN_MANIFEST ${MICROPY_USER_FROZEN_MANIFEST})
|
|
|
|
elseif (NOT MICROPY_FROZEN_MANIFEST)
|
|
|
|
set(MICROPY_FROZEN_MANIFEST ${MICROPY_PORT_DIR}/boards/manifest.py)
|
|
|
|
endif()
|
|
|
|
|
2021-05-13 05:10:06 +01:00
|
|
|
# Add sdkconfig fragments that depend on the IDF version.
|
|
|
|
if(IDF_VERSION_MAJOR EQUAL 4 AND IDF_VERSION_MINOR LESS 2)
|
|
|
|
set(SDKCONFIG_DEFAULTS ${SDKCONFIG_DEFAULTS} boards/sdkconfig.nimble_core0)
|
|
|
|
else()
|
|
|
|
set(SDKCONFIG_DEFAULTS ${SDKCONFIG_DEFAULTS} boards/sdkconfig.nimble_core1)
|
|
|
|
endif()
|
|
|
|
|
2020-09-23 06:55:55 +01:00
|
|
|
# Concatenate all sdkconfig files into a combined one for the IDF to use.
|
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}/sdkconfig.combined.in "")
|
|
|
|
foreach(SDKCONFIG_DEFAULT ${SDKCONFIG_DEFAULTS})
|
|
|
|
file(READ ${SDKCONFIG_DEFAULT} CONTENTS)
|
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}/sdkconfig.combined.in "${CONTENTS}")
|
|
|
|
endforeach()
|
|
|
|
configure_file(${CMAKE_BINARY_DIR}/sdkconfig.combined.in ${CMAKE_BINARY_DIR}/sdkconfig.combined COPYONLY)
|
|
|
|
set(SDKCONFIG_DEFAULTS ${CMAKE_BINARY_DIR}/sdkconfig.combined)
|
|
|
|
|
2021-05-13 05:10:06 +01:00
|
|
|
# Define the project.
|
2020-09-23 06:55:55 +01:00
|
|
|
project(micropython)
|