43 lines
1.4 KiB
CMake
43 lines
1.4 KiB
CMake
include(CMake/githash.cmake)
|
|
|
|
# All required source definitions
|
|
file(GLOB_RECURSE SOURCES
|
|
"Core/*.*"
|
|
"Middlewares/*.*"
|
|
"Drivers/*.*"
|
|
"USB_DEVICE/*.*"
|
|
)
|
|
|
|
# Check if the correct toolchain was used and the LINKER_SCRIPT is defined
|
|
if(NOT DEFINED LINKER_SCRIPT)
|
|
message(FATAL_ERROR "You need to define the LINKER_SCRIPT variable from within the toolchain for the correct MCU")
|
|
endif()
|
|
|
|
add_executable(FloatPUMP.elf ${SOURCES} ${LINKER_SCRIPT})
|
|
|
|
# Custom target options
|
|
target_compile_definitions(FloatPUMP.elf PUBLIC
|
|
"-DGIT_HASH=\"${GIT_HASH}\""
|
|
)
|
|
|
|
target_include_directories(${PROJECT_NAME}.elf PUBLIC
|
|
USB_DEVICE/App
|
|
USB_DEVICE/Target
|
|
Core/Inc
|
|
Drivers/STM32F4xx_HAL_Driver/Inc
|
|
Drivers/STM32F4xx_HAL_Driver/Inc/Legacy
|
|
Middlewares/ST/STM32_USB_Device_Library/Core/Inc
|
|
Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc
|
|
Drivers/CMSIS/Device/ST/STM32F4xx/Include
|
|
Drivers/CMSIS/Include
|
|
Middlewares/floatpump/Inc
|
|
)
|
|
|
|
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}") |