-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
35 lines (26 loc) · 1.35 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
cmake_minimum_required(VERSION 3.1)
project(firmware C CXX ASM)
add_definitions(-DSTM32F030x6)
# Set the C/C++ standards
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(MCU "cortex-m0")
set(CFCOMMON "-mcpu=${MCU} -mthumb --specs=nano.specs --specs=nosys.specs -Wall -fmessage-length=0 -ffunction-sections -fdata-sections")
set(CFRELEASE "-Os")
set(CFDEBUG "-O0 -g")
include(cmake/cmsis.cmake)
file(GLOB SOURCE_FILES "src/*.c" "src/*.cpp" "*.s")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CFDEBUG} ${CFCOMMON} -fno-exceptions")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CFDEBUG} ${CFCOMMON}")
set(CMAKE_ASM_FLAGS "${COMMON_COMPILE_FLAGS} -x assembler-with-cpp")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${CMAKE_SOURCE_DIR}/STM32F030F4Px_FLASH.ld -Wl,--gc-sections")
add_executable(${PROJECT_NAME}.elf ${SOURCE_FILES})
add_custom_command(TARGET "${PROJECT_NAME}.elf" POST_BUILD
# Build .hex and .bin files
COMMAND ${OBJCOPY} -Obinary "${PROJECT_NAME}.elf" "${PROJECT_NAME}.bin"
COMMAND ${OBJCOPY} -Oihex "${PROJECT_NAME}.elf" "${PROJECT_NAME}.hex"
COMMENT "Building ${PROJECT_NAME}.bin and ${PROJECT_NAME}.hex"
# Display sizes
COMMAND ${SIZE} --format=berkeley ${PROJECT_NAME}.elf
COMMENT "Invoking: Cross ARM GNU Print Size" )