-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
139 lines (114 loc) · 2.86 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
cmake_policy(SET CMP0048 NEW)
cmake_minimum_required(VERSION 3.13.0)
get_filename_component(APPLICATION ${CMAKE_CURRENT_SOURCE_DIR} NAME_WE)
if (NOT "$ENV{APPLICATION_NAME}" STREQUAL "")
set(APPLICATION_NAME $ENV{APPLICATION_NAME})
else()
set(APPLICATION_NAME ${APPLICATION}_${CMAKE_VARIANT_BSP}_${CMAKE_BUILD_TYPE})
endif()
option(CLI_ENABLE "" ON)
option(BSP_NM180100EVB "" OFF)
option(BSP_NM180410 "" OFF)
option(BSP_NM180411 "" OFF)
option(FEATURE_RAT_BLE_ENABLE "" OFF)
option(FEATURE_RAT_LORAWAN_ENABLE "" OFF)
option(FEATURE_RAT_LORA_MESH_ENABLE "" OFF)
option(FEATURE_TF_ENABLE "" OFF)
if (BSP_NM180100EVB)
add_definitions(-DBSP_NM180100EVB)
set(NM_TARGET "nm180100")
set(BSP_TARGET_DIR nm180100evb CACHE STRING "" FORCE)
endif()
if (BSP_NM180410)
add_definitions(-DBSP_NM180410)
set(NM_TARGET "nm180100")
set(BSP_TARGET_DIR nm180410 CACHE STRING "" FORCE)
endif()
if (BSP_NM180411)
add_definitions(-DBSP_NM180411)
set(NM_TARGET "nm180110")
set(BSP_TARGET_DIR nm180411 CACHE STRING "" FORCE)
endif()
add_definitions(-DNMI)
add_subdirectory(nmsdk2)
project(${APPLICATION})
add_executable(${APPLICATION})
set_target_properties(
${APPLICATION}
PROPERTIES
OUTPUT_NAME ${APPLICATION_NAME}
SUFFIX ".axf"
)
add_subdirectory(version)
add_subdirectory(bsp)
if (BUILD_HAL)
add_dependencies(${APPLICATION} hal)
endif()
if (BUILD_RTOS)
add_dependencies(${APPLICATION} rtos)
endif()
target_link_libraries(
${APPLICATION}
PUBLIC
-T${TARGET_LINK_SCRIPT}
-static
-Wl,--start-group
nm_sdk_version
nm_app_version
${RTOS_LIBS}
bsp
${HAL_LIBS}
-lm
-lc
-lgcc
-Wl,--end-group
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:OUTPUT_NAME>.map
-Wl,--print-memory-usage
)
target_compile_definitions(
${APPLICATION}
PRIVATE
)
target_include_directories(
${APPLICATION}
PRIVATE
${HAL_INCLUDES}
${RTOS_INCLUDES}
${BSP_INCLUDES}
${PROJECT_SOURCE_DIR}/version
${PROJECT_SOURCE_DIR}
${SDK_DIR}/version
${SDK_DIR}/middleware/RTT/Config
${SDK_DIR}/middleware/RTT/RTT
${PROJECT_SOURCE_DIR}/ui
)
if (CLI_ENABLE)
add_definitions(-DCLI_ENABLE)
set(
CLI_SOURCES
console_task.c
application_task_cli.c
ui/led_task_cli.c
)
endif()
target_sources(
${APPLICATION}
PRIVATE
${TARGET_STARTUP_SRC}
${TARGET_NEWLIB_STUB_SRC}
${CLI_SOURCES}
main.c
application_task.c
${SDK_DIR}/middleware/RTT/RTT/SEGGER_RTT.c
${SDK_DIR}/middleware/RTT/RTT/SEGGER_RTT_printf.c
ui/button_task.c
ui/led_task.c
ui/led_predefined_effects.c
)
add_custom_command(
TARGET ${APPLICATION}
POST_BUILD
COMMAND echo "Creating bin file"
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE_NAME:${APPLICATION}> $<TARGET_FILE_BASE_NAME:${APPLICATION}>.bin
)