Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
micropython/ports/esp32/CMakeLists.txt
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
66 lines (52 sloc)
2.44 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Top-level cmake file for building MicroPython on ESP32. | |
cmake_minimum_required(VERSION 3.12) | |
# Retrieve IDF version | |
include($ENV{IDF_PATH}/tools/cmake/version.cmake) | |
set(IDF_VERSION "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}") | |
# Set the board if it's not already set. | |
if(NOT MICROPY_BOARD) | |
set(MICROPY_BOARD ESP32_GENERIC) | |
endif() | |
# Set the board directory and check that it exists. | |
if(NOT MICROPY_BOARD_DIR) | |
set(MICROPY_BOARD_DIR ${CMAKE_CURRENT_LIST_DIR}/boards/${MICROPY_BOARD}) | |
endif() | |
if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigboard.cmake) | |
message(FATAL_ERROR "Invalid MICROPY_BOARD specified: ${MICROPY_BOARD}") | |
endif() | |
# Define the output sdkconfig so it goes in the build directory. | |
set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig) | |
# Save the manifest file set from the cmake command line. | |
set(MICROPY_USER_FROZEN_MANIFEST ${MICROPY_FROZEN_MANIFEST}) | |
# Specific options for IDF v5.2 and later | |
set(SDKCONFIG_IDF_VERSION_SPECIFIC "") | |
if (IDF_VERSION VERSION_GREATER_EQUAL "5.2.0") | |
set(SDKCONFIG_IDF_VERSION_SPECIFIC boards/sdkconfig.idf52) | |
endif() | |
# Include board config; this is expected to set (among other options): | |
# - SDKCONFIG_DEFAULTS | |
# - IDF_TARGET | |
include(${MICROPY_BOARD_DIR}/mpconfigboard.cmake) | |
# 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 ${CMAKE_CURRENT_LIST_DIR}/boards/manifest.py) | |
endif() | |
# 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) | |
# Include main IDF cmake file. | |
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | |
# Set the location of the main component for the project (one per target). | |
list(APPEND EXTRA_COMPONENT_DIRS main_${IDF_TARGET}) | |
# Enable the panic handler wrapper | |
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND) | |
# Define the project. | |
project(micropython) |