23 lines
909 B
CMake
23 lines
909 B
CMake
# For more information about build system see
|
|
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
|
|
# The following five lines of boilerplate have to be in your project's
|
|
# CMakeLists in this exact order for cmake to work correctly
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
# 强制使用 Ninja 构建系统
|
|
set(CMAKE_GENERATOR "Ninja")
|
|
|
|
# 生成 compile_commands.json 用于 clangd
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
|
project(my_usb_project)
|
|
|
|
# 添加链接器选项来抑制 .note.GNU-stack 警告
|
|
target_link_options(${CMAKE_PROJECT_NAME}.elf PRIVATE "-Wl,-z,noexecstack")
|
|
|
|
# 添加自定义链接器脚本修复
|
|
add_custom_command(TARGET ${CMAKE_PROJECT_NAME}.elf POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/fix_linker_script.cmake
|
|
COMMENT "Applying linker script fix for Rust rodata alignment"
|
|
) |