1cmake_minimum_required(VERSION 3.20.0) 2 3set(CMAKE_C_COMPILER arm-zephyr-eabi-gcc) 4set(CMAKE_FIND_ROOT_PATH $ENV{ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi) 5set(CMAKE_C_COMPILER_FORCED TRUE) 6set(CMAKE_CXX_COMPILER_FORCED TRUE) 7 8project(extension) 9 10include($ENV{LLEXT_EDK_INSTALL_DIR}/cmake.cflags) 11 12# Add LLEXT_CFLAGS to our flags 13add_compile_options(${LLEXT_CFLAGS}) 14add_compile_options("-Werror") 15add_compile_options("-c") 16 17# Get flags from COMPILE_OPTIONS 18get_property(COMPILE_OPTIONS_PROP DIRECTORY PROPERTY COMPILE_OPTIONS) 19 20add_custom_command( 21 OUTPUT 22 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.llext 23 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.inc 24 COMMAND ${CMAKE_C_COMPILER} ${COMPILE_OPTIONS_PROP} 25 -o ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.llext 26 ${PROJECT_SOURCE_DIR}/src/main.c 27 COMMAND 28 ${PYTHON_EXECUTABLE} 29 ${PROJECT_SOURCE_DIR}/file2hex.py 30 --file ${PROJECT_NAME}.llext 31 > ${PROJECT_NAME}.inc 32) 33 34add_custom_target(extension ALL DEPENDS ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.llext) 35