0

我正在尝试从https://docs.micropython.org/en/latest/develop/porting.html将 micropython makefile 转换为 cmakelists.txt

# Include the core environment definitions; this will set $(TOP).
include ../../py/mkenv.mk

# Include py core make definitions.
include $(TOP)/py/py.mk

# Set CFLAGS and libraries.
CFLAGS = -I. -I$(BUILD) -I$(TOP)
LIBS = -lm
CROSS_COMPILE ?= arm-none-eabi-

# Define the required source files.
SRC_C = \
    main.c \
    mphalport.c \
    lib/mp-readline/readline.c \
    lib/utils/gchelper_generic.c \
    lib/utils/pyexec.c \
    lib/utils/stdout_helpers.c \

# Define the required object files.
OBJ = $(PY_CORE_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))

# Define the top-level target, the main firmware.
all: $(BUILD)/firmware.elf

# Define how to build the firmware.
$(BUILD)/firmware.elf: $(OBJ)
    $(ECHO) "LINK $@"
    $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
    $(Q)$(SIZE) $@

# Include remaining core make rules.
include $(TOP)/py/mkrules.mk

cmakelists.txt 的当前进展

cmake_minimum_required(VERSION 3.17)
set(CMAKE_CXX_STANDARD 14)

set(MICROPY_TARGET firmware)
set(MICROPY_DIR "../..")
set(MICROPY_PORT_DIR    ${CMAKE_CURRENT_SOURCE_DIR})

include(${MICROPY_DIR}/py/py.cmake)
project(${MICROPY_TARGET})

set(MICROPY_SOURCE_PORT
        ${MICROPY_PORT_DIR}/main.c
        ${MICROPY_PORT_DIR}/mphalport.c
        ${MICROPY_DIR}/lib/mp-readline/readline.c
        ${MICROPY_DIR}/lib/utils/gchelper_generic.c
        ${MICROPY_DIR}/lib/utils/pyexec.c
        ${MICROPY_DIR}/lib/utils/stdout_helpers.c
        )

target_sources(app PRIVATE
        ${MICROPY_SOURCE_PY}
        ${MICROPY_SOURCE_PORT}
        )

target_link_libraries(app PRIVATE ${MICROPY_TARGET})

include(${MICROPY_DIR}/py/mkrules.cmake)

运行时出现错误:

第 33 行的 CMake 错误:无法指定不是由该项目构建的目标“应用程序”的源。

我正在从中获得帮助:https ://github.com/micropython/micropython/blob/master/ports/zephyr/CMakeLists.txt ,但我认为我缺少一些步骤。

4

0 回答 0