软件
mingw
cmake
gcc-arm-none-eabi-gcc
并添加环境变量
文件结构
├─Bsp
│ ├─driver_time
│ └─driver_uart
├─cmake
├─Component
│ └─Fifo
├─Driver
│ ├─Inc
│ └─Src
├─Lib
│ ├─CMSIS
│ │ ├─Core
│ │ │ └─Include
│ │ └─Device
│ │ └─ST
│ │ └─STM32F7xx
│ │ └─Include
│ └─STM32F7xx_HAL_Driver
│ ├─Inc
│ │ └─Legacy
│ └─Src
├─Link
├─Start_up
└─User
执行脚本
build.bat
@echo off
set dir_path= %cd%
set cmake_path=\tools\cmake-3.27.0-windows-x86_64\bin
set gcc_path=\tools\gcc-arm-none-eabi-10.3-2021.10\bin
set mingw_path=tools\MinGW64\bin
@REM echo %dir_path%%gcc_path%
@REM echo %dir_path%%cmake_path%
set path=%dir_path%%gcc_path%;%path%
set path=%dir_path%%cmake_path%;%path%
set path=%dir_path%%mingw_path%;%path%
@REM echo %PATH%
IF /i "%1"=="-C" (
rd /s /q build
) ELSE IF /i "%1"=="" (
IF EXIST build (
cd build
cmake -G "MinGW Makefiles" ..
make
cd ..
) ELSE (
md build
cd build
cmake -G "MinGW Makefiles" ..
make
cd ..
)
)
简单的cmake 模板
# No operating system
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
cmake_minimum_required(VERSION 3.21)
# specify cross compilers and tools
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
set(CMAKE_AR arm-none-eabi-ar)
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
set(CMAKE_OBJDUMP arm-none-eabi-objdump)
set(SIZE arm-none-eabi-size)
# skip compiler checks
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
project(MiniBot C CXX ASM)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
add_compile_options(-mcpu=cortex-m3 -mthumb -mthumb-interwork)
add_compile_options(-ffunction-sections -fdata-sections -fno-common -fmessage-length=0)
# uncomment to mitigate c++17 absolute addresses warnings
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register")
# Enable assembler files preprocessing
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-x$<SEMICOLON>assembler-with-cpp>)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message(STATUS "Maximum optimization for speed")
add_compile_options(-Ofast)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
message(STATUS "Maximum optimization for speed, debug info included")
add_compile_options(-Ofast -g)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
message(STATUS "Maximum optimization for size")
add_compile_options(-Os)
else ()
message(STATUS "Minimal optimization, debug info included")
add_compile_options(-Og -g)
endif ()
include_directories(
./
# ${CMAKE_SOURCE_DIR}/drivers/CMSIS/Include
# ${CMAKE_SOURCE_DIR}/drivers/CMSIS/Device/ST/STM32F1xx/Include
# ${CMAKE_SOURCE_DIR}/drivers/STM32F1xx_HAL_Driver/Inc
# ${CMAKE_SOURCE_DIR}/drivers/STM32F1xx_HAL_Driver/Inc/Legacy
# ${CMAKE_SOURCE_DIR}/main
)
add_definitions(-DUSE_HAL_DRIVER -D__MICROLIB -DSTM32F1 -DSTM32F1xx -DSTM32F103xB)
# aux_source_directory(${CMAKE_SOURCE_DIR}/drivers/STM32F1xx_HAL_Driver/Src HAL_DRIVER)
# aux_source_directory(${CMAKE_SOURCE_DIR}/drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates SYSTEM)
# aux_source_directory(${CMAKE_SOURCE_DIR}/main MAIN)
aux_source_directory(${CMAKE_SOURCE_DIR}/User USER)
set(STARTUP ${CMAKE_SOURCE_DIR}/startup/startup_stm32f103xb.s)
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/Link/STM32F103C8Tx_FLASH.ld)
add_link_options(-Wl,-gc-sections,--print-memory-usage,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map)
add_link_options(-mcpu=cortex-m3 -mthumb -mthumb-interwork)
add_link_options(-T ${LINKER_SCRIPT})
add_executable(${PROJECT_NAME}.elf ${USER} ${STARTUP} ${LINKER_SCRIPT})
set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
COMMENT "Building ${HEX_FILE}
Building ${BIN_FILE}")
多个文件模板
cmake/arm-none-eabi.cmake
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_C_COMPILER ${CROSS_COMPILE_PREFIX}gcc)
set(CMAKE_CXX_COMPILER ${CROSS_COMPILE_PREFIX}g++)
set(CMAKE_ASM_COMPILER ${CROSS_COMPILE_PREFIX}gcc)
set(CMAKE_AR ${CROSS_COMPILE_PREFIX}ar)
set(CMAKE_OBJCOPY ${CROSS_COMPILE_PREFIX}objcopy)
set(CMAKE_OBJDUMP ${CROSS_COMPILE_PREFIX}objdump)
set(SIZE ${CROSS_COMPILE_PREFIX}size)
# 设置c++ c 标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
cmake/cortex_m0.cmake
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_PROCESSOR cortex-m0)
SET(MCPU_FLAGS "-mcpu=cortex-m0 -mthumb")
SET(VFP_FLAGS "")
ADD_DEFINITIONS(
-DARM_MATH_CM0
)
cmake/cortex_m3.cmake
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_PROCESSOR cortex-m3)
#添加 编译标志
SET(MCPU_FLAGS "-mthumb -mthumb-interwork -mcpu=cortex-m3")
#添加浮点运算标准
SET(VFP_FLAGS "-mfloat-abi=soft")
add_definitions(
-DUSE_HAL_DRIVER
-DSTM32F1
)
cmake/cortex_m4.cmake
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_PROCESSOR cortex-m4)
SET(MCPU_FLAGS "-mthumb -mcpu=cortex-m4")
SET(VFP_FLAGS "-mfloat-abi=soft")
ADD_DEFINITIONS(
-DARM_MATH_CM4
-DARM_MATH_MATRIX_CHECK
-DARM_MATH_ROUNDING
-D__FPU_PRESENT=1
)
cmake/cortex_m7.cmake
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_PROCESSOR cortex-m4)
SET(FPU "-mfpu=fpv5-d16")
SET(MCPU_FLAGS "-mthumb -mcpu=cortex-m7 ${FPU}")
SET(VFP_FLAGS "-mfloat-abi=hard")
ADD_DEFINITIONS(
-DUSE_HAL_DRIVER
)
cmake/gcc-flags.cmake
#判断包含架构文件
if(CMAKE_ARCH_TYPE MATCHES CM0)
include(${CMAKE_SOURCE_DIR}/cmake/cortex_m0.cmake)
elseif(CMAKE_ARCH_TYPE MATCHES CM3)
include(${CMAKE_SOURCE_DIR}/cmake/cortex_m3.cmake)
elseif(CMAKE_ARCH_TYPE MATCHES CM4)
include(${CMAKE_SOURCE_DIR}/cmake/cortex_m4.cmake)
elseif(CMAKE_ARCH_TYPE MATCHES CM7)
include(${CMAKE_SOURCE_DIR}/cmake/cortex_m7.cmake)
endif()
# 设置编译选项
# 定义通用编译器参数; ${MCPU_FLAGS} 处理器内核信息 ${VFP_FLAGS} 浮点运算单元类型
SET(CFCOMMON
"${MCPU_FLAGS} ${VFP_FLAGS} --specs=nano.specs -specs=rdimon.specs --specs=nosys.specs -Wall -fmessage-length=0 -ffunction-sections -fdata-sections"
)
# 定义最快运行速度发行模式的编译参数;
SET(CMAKE_C_FLAGS_RELEASE "-Os ${CFCOMMON}")
SET(CMAKE_CXX_FLAGS_RELEASE "-Os ${CFCOMMON} -fno-exceptions")
SET(CMAKE_ASM_FLAGS_RELEASE "${MCPU_FLAGS} ${VFP_FLAGS} -x assembler-with-cpp")
# 定义最小尺寸且包含调试信息的编译参数;
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g ${CFCOMMON}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -g ${CFCOMMON} -fno-exceptions")
SET(CMAKE_ASM_FLAGS_RELWITHDEBINFO "${MCPU_FLAGS} ${VFP_FLAGS} -x assembler-with-cpp")
# 定义最小尺寸的编译参数;
SET(CMAKE_C_FLAGS_MINSIZEREL "-Os ${CFCOMMON}")
SET(CMAKE_CXX_FLAGS_MINSIZEREL "-Os ${CFCOMMON} -fno-exceptions")
SET(CMAKE_ASM_FLAGS_MINSIZEREL "${MCPU_FLAGS} ${VFP_FLAGS} -x assembler-with-cpp")
# 定义调试模式编译参数;
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g ${CFCOMMON}")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g ${CFCOMMON} -fno-exceptions")
SET(CMAKE_ASM_FLAGS_DEBUG "${MCPU_FLAGS} ${VFP_FLAGS} -x assembler-with-cpp")
SET(CMAKE_EXE_LINKER_FLAGS " -T ${LINKER_SCRIPT} -lnosys -Wl,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map -Wl,--gc-sections,--print-memory-usage")
cmake/postbuild.cmake
set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
COMMENT "Building ${HEX_FILE}
Building ${BIN_FILE}")
根目录
CMakeLists.txt
├─Bsp
├─cmake
├─Component
├─Driver
├─Lib
├─Link
├─Start_up
└─User
set(CROSS_COMPILE_PREFIX arm-none-eabi-)
include(${CMAKE_SOURCE_DIR}/cmake/arm-none-eabi.cmake)
cmake_minimum_required(VERSION 3.21)
SET(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
#显示编译过程
set ( CMAKE_VERBOSE_MAKEFILE off )
# 项目名称
project(stm32f767_project)
# 开启汇编
ENABLE_LANGUAGE( ASM)
# 项目构建类型
set(CMAKE_BUILD_TYPE "Debug")
#set(CMAKE_BUILD_TYPE "Release")
#set(CMAKE_BUILD_TYPE "RelWithDebInfo")
#set(CMAKE_BUILD_TYPE "MinSizeRel")
# 设置内核架构
set(CMAKE_ARCH_TYPE "CM7")
# 添加头文件路径
include_directories(
./
./User
)
#添加源码路径
aux_source_directory(${CMAKE_SOURCE_DIR}/User USER)
#添加启动代码路径
set(STARTUP ${CMAKE_SOURCE_DIR}/Start_up/startup_stm32f767xx.s)
#添加链接脚本路径
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/Link/STM32F767IGTx_FLASH.ld)
# 宏定义
add_definitions(
-DSTM32F767xx
)
# 保护 架构 flag cmake文件
include(${CMAKE_SOURCE_DIR}/cmake/gcc-flags.cmake)
# 打印 构建信息
MESSAGE(STATUS "-----------------------------------------------")
IF("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
MESSAGE(STATUS "**** Maximum optimization for speed ****")
ELSEIF("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
MESSAGE(STATUS "**** Maximum optimization for size, debug info included ****")
ELSEIF("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
MESSAGE(STATUS "**** Maximum optimization for size ****")
ELSE() # "Debug"
MESSAGE(STATUS "**** No optimization, debug info included ****")
ENDIF()
MESSAGE(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS} ")
MESSAGE(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS} ")
MESSAGE(STATUS "CMAKE_ASM_FLAGS: ${CMAKE_ASM_FLAGS} ")
MESSAGE(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS} ")
MESSAGE(STATUS "-----------------------------------------------")
#生成目标文件
add_executable(${PROJECT_NAME}.elf
${STARTUP}
${LINKER_SCRIPT}
${USER}
)
# 添加子文件
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Driver)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Bsp)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Lib)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Component)
include(${CMAKE_SOURCE_DIR}/cmake/postbuild.cmake)
bsp
CMakeLists.txt
├─Bsp
│ ├─driver_time
│ └─driver_uart
TARGET_SOURCES(
${PROJECT_NAME}.elf
PRIVATE # {{BEGIN_TARGET_SOURCES}}
${CMAKE_CURRENT_LIST_DIR}/driver_time/driver_time.c
${CMAKE_CURRENT_LIST_DIR}/driver_time/driver_time_cfg.c
# {{END_TARGET_SOURCES}}
# {{BEGIN_TARGET_SOURCES}}
${CMAKE_CURRENT_LIST_DIR}/driver_uart/driver_uart.c
${CMAKE_CURRENT_LIST_DIR}/driver_uart/driver_uart_callout.c
${CMAKE_CURRENT_LIST_DIR}/driver_uart/driver_uart_cfg.c
# {{END_TARGET_SOURCES}}
)
# Add the Common/inc directory to the project include list
TARGET_INCLUDE_DIRECTORIES( ${PROJECT_NAME}.elf PUBLIC
${CMAKE_CURRENT_LIST_DIR}/driver_time
${CMAKE_CURRENT_LIST_DIR}/driver_uart
)
Component
CMakeLists.txt
├─Component
│ └─Fifo
TARGET_SOURCES(
${PROJECT_NAME}.elf
PRIVATE # {{BEGIN_TARGET_SOURCES}}
${CMAKE_CURRENT_LIST_DIR}/Fifo/Fifo.c
# {{END_TARGET_SOURCES}}
)
# Add the Common/inc directory to the project include list
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}.elf PUBLIC
${CMAKE_CURRENT_LIST_DIR}/Fifo)
Lib
CMakeLists.txt文章来源:https://www.toymoban.com/news/detail-676384.html
├─Lib
│ ├─CMSIS
│ │ ├─Core
│ │ │ └─Include
│ │ └─Device
│ │ └─ST
│ │ └─STM32F7xx
│ │ └─Include
│ └─STM32F7xx_HAL_Driver
│ ├─Inc
│ │ └─Legacy
│ └─Src
TARGET_SOURCES(
${PROJECT_NAME}.elf
PRIVATE # {{BEGIN_TARGET_SOURCES}}
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_adc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_adc_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_can.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cec.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_crc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_crc_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cryp.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cryp_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dac.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dac_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dcmi.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dcmi_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dfsdm.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma2d.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dsi.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_eth.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_exti.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_gpio.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_hash.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_hash_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_hcd.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2s.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_irda.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_iwdg.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_jpeg.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_lptim.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_ltdc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_ltdc_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_mdios.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_mmc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_nand.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_nor.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_qspi.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rng.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rtc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rtc_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_sai.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_sai_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_sd.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_sdram.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_smartcard.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_smartcard_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_smbus.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_spdifrx.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_spi.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_spi_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_sram.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_uart.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_uart_ex.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_usart.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_wwdg.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_adc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_crc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_dac.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_dma.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_dma2d.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_exti.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_fmc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_gpio.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_i2c.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_lptim.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_pwr.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_rcc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_rng.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_rtc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_sdmmc.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_spi.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_tim.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usart.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_utils.c
# {{END_TARGET_SOURCES}}
)
# Add the Common/inc directory to the project include list
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}.elf PUBLIC
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Inc
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Inc
${CMAKE_CURRENT_LIST_DIR}/STM32F7xx_HAL_Driver/Inc/Legacy
${CMAKE_CURRENT_LIST_DIR}/CMSIS/Include
${CMAKE_CURRENT_LIST_DIR}/CMSIS/Core/Include
${CMAKE_CURRENT_LIST_DIR}/CMSIS/Device/ST/STM32F7xx/Include
)
Driver
CMakeLists.txt文章来源地址https://www.toymoban.com/news/detail-676384.html
├─Driver
│ ├─Inc
│ └─Src
TARGET_SOURCES(
${PROJECT_NAME}.elf
PRIVATE # {{BEGIN_TARGET_SOURCES}}
${CMAKE_CURRENT_LIST_DIR}/Src/gpio.c
${CMAKE_CURRENT_LIST_DIR}/Src/stm32f7xx_hal_msp.c
${CMAKE_CURRENT_LIST_DIR}/Src/stm32f7xx_it.c
${CMAKE_CURRENT_LIST_DIR}/Src/system_stm32f7xx.c
${CMAKE_CURRENT_LIST_DIR}/Src/tim.c
${CMAKE_CURRENT_LIST_DIR}/Src/usart.c
# {{END_TARGET_SOURCES}}
)
# Add the Common/inc directory to the project include list
TARGET_INCLUDE_DIRECTORIES( ${PROJECT_NAME}.elf PUBLIC
${CMAKE_CURRENT_LIST_DIR}/Inc
)
到了这里,关于cmake stm32 模板的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!