-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
93 lines (79 loc) · 2.43 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
cmake_minimum_required(VERSION 3.10)
include("ide/cmake/arm-none-eabi.cmake")
# project name
project(lv_stm32f746 C ASM)
# select linker script
set(LINKER_SCRIPT "LinkerScript.ld")
# define CPU OPTIONS
set(CPU_OPTIONS -mthumb -march=armv7e-m)
# optimizations (-O0 -O1 -O2 -O3 -Os -Ofast -Og -flto)
set(CMAKE_C_FLAGS_DEBUG "-Og -g -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
set(CMAKE_C_FLAGS_RELEASE "-Os")
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s)
add_compile_options(
${CPU_OPTIONS}
$<$<COMPILE_LANGUAGE:C>:-std=gnu99>
$<$<COMPILE_LANGUAGE:CXX>:-std=c++17>
$<$<COMPILE_LANGUAGE:CXX>:-fms-extensions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
$<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>
$<$<COMPILE_LANGUAGE:CXX>:-fno-threadsafe-statics>
-fstrict-volatile-bitfields
-ffunction-sections
-fdata-sections
-Wall
-Wshadow
)
include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/inc
${CMAKE_SOURCE_DIR}/HAL_Driver/Inc
${CMAKE_SOURCE_DIR}/CMSIS/device
${CMAKE_SOURCE_DIR}/CMSIS/core
${CMAKE_SOURCE_DIR}/lvgl
${CMAKE_SOURCE_DIR}/lv_examples
${CMAKE_SOURCE_DIR}/Utilities/STM32746G-Discovery
)
link_directories(
${CMAKE_SOURCE_DIR}
)
FILE(GLOB_RECURSE HAL_Sources HAL_Driver/Src/*.c
Utilities/STM32746G-Discovery/stm32746g_discovery_ts.c
Utilities/Components/ft5336/ft5336.c
Utilities/STM32746G-Discovery/stm32746g_discovery.c
Utilities/STM32746G-Discovery/stm32746g_discovery_sdram.c
)
FILE(GLOB_RECURSE LVGL_Sources CONFIGURE_DEPENDS lvgl/src/*.c lv_examples/*.c hal_stm_lvgl/*.c)
add_definitions(
-DSTM32
-DSTM32F7
-DSTM32F746G_DISCO
-DDEBUG
-DSTM32F746xx
-DUSE_HAL_DRIVER
)
# list of modules to build final firmware (without extension .c or .cpp)
add_executable(${PROJECT_NAME}
src/main
src/stm32f7xx_it
src/syscalls
src/system_stm32f7xx
startup/startup_stm32f746xx.s
${HAL_Sources}
${LVGL_Sources}
)
target_link_libraries(${PROJECT_NAME}
${CPU_OPTIONS}
-T${LINKER_SCRIPT}
-nodefaultlibs
-Wl,--gc-sections
m
# -nostdlib
)
add_custom_target(${PROJECT_NAME}.bin ALL DEPENDS ${PROJECT_NAME})
add_custom_command(TARGET ${PROJECT_NAME}.bin
COMMAND ${CMAKE_C_OBJCOPY} ARGS -O binary ${PROJECT_NAME} ${PROJECT_NAME}.bin)
set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_DEPENDS ${CMAKE_SOURCE_DIR}/${LINKER_SCRIPT})