88 lines
2.1 KiB
CMake
88 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.22)
|
|
|
|
#
|
|
# This file is generated only once,
|
|
# and is not re-generated if converter is called multiple times.
|
|
#
|
|
# User is free to modify the file as much as necessary
|
|
#
|
|
|
|
# Setup compiler settings
|
|
set(CMAKE_C_STANDARD 11)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
set(CMAKE_C_EXTENSIONS ON)
|
|
|
|
|
|
# Define the build type
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
|
endif()
|
|
|
|
# Set the project name
|
|
set(CMAKE_PROJECT_NAME proj2)
|
|
|
|
# Enable compile command to ease indexing with e.g. clangd
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
|
|
|
# Core project settings
|
|
project(${CMAKE_PROJECT_NAME})
|
|
message("Build type: " ${CMAKE_BUILD_TYPE})
|
|
|
|
# Enable CMake support for ASM and C languages
|
|
enable_language(C ASM)
|
|
|
|
# Create an executable object type
|
|
add_executable(${CMAKE_PROJECT_NAME})
|
|
|
|
# Add STM32CubeMX generated sources
|
|
add_subdirectory(cmake/stm32cubemx)
|
|
add_subdirectory(KPI_Rover)
|
|
#add_subdirectory(Middlewares/ST/STM32_USB_Device_Library)
|
|
|
|
|
|
if (DEFINED BUILD_TEST)
|
|
# TODO: add replacement files
|
|
else()
|
|
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
|
|
${CMAKE_SOURCE_DIR}/Core/init.c
|
|
${CMAKE_SOURCE_DIR}/Core/haldev.c
|
|
${CMAKE_SOURCE_DIR}/Core/interrupts.c
|
|
${CMAKE_SOURCE_DIR}/Core/syscalls.c
|
|
${CMAKE_SOURCE_DIR}/Core/sysmem.c
|
|
${CMAKE_SOURCE_DIR}/startup_stm32f407xx.s
|
|
)
|
|
endif()
|
|
|
|
# Remove wrong libob.a library dependency when using cpp files
|
|
list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_LIBRARIES ob)
|
|
|
|
# Add linked libraries
|
|
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
|
|
STM32HAL
|
|
FREERTOS
|
|
KPI_Rover
|
|
HAL_H
|
|
FREERTOS_H
|
|
KPI_Rover_H
|
|
)
|
|
|
|
add_custom_target(flash
|
|
COMMAND echo "Flash command ran 1!"
|
|
COMMAND echo "Flash command ran 2!"
|
|
COMMAND echo "$$PWD"
|
|
COMMAND ${TOOLCHAIN_PREFIX}objcopy -O binary proj2.elf proj2.bin
|
|
COMMAND st-flash --connect-under-reset write proj2.bin 0x08000000
|
|
BYPRODUCTS proj2.bin
|
|
DEPENDS ${CMAKE_PROJECT_NAME}
|
|
)
|
|
|
|
#add_custom_target(debug
|
|
# COMMAND echo "Flash command ran 1!"
|
|
# COMMAND echo "Flash command ran 2!"
|
|
# COMMAND echo "$$PWD"
|
|
# COMMAND st-util &
|
|
# COMMAND ${TOOLCHAIN_PREFIX}gdb -ex 'target extended-remote:4242' proj2.elf
|
|
# COMMAND kill %1
|
|
# DEPENDS flash
|
|
#)
|