-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
73 lines (55 loc) · 1.77 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
cmake_minimum_required(VERSION 3.15.1)
# toolchain file
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/arm-none-eabi.cmake)
# project
project(amk VERSION 1.0.0)
enable_language(C ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
if(NOT DEFINED KEYBOARD)
set(KEYBOARD onekey)
endif()
set(KEYBOARD_DIR ${CMAKE_CURRENT_LIST_DIR}/keyboards/${KEYBOARD} )
include(${KEYBOARD_DIR}/${KEYBOARD}.cmake)
set_target_properties(${KEYBOARD} PROPERTIES OUTPUT_NAME "${KEYBOARD}.elf")
set(SDK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sdk_${MCU_FAMILY})
add_subdirectory(${SDK_DIR})
set(MAIN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/main)
add_subdirectory(${MAIN_DIR})
#always enabled tmk feature
set(MOUSEKEY_ENABLE yes)
set(EXTRAKEY_ENABLE yes)
set(LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs)
add_subdirectory(${LIBS_DIR})
message(STATUS "LDFLAGS:-L${LINKER_PATH} -T${LINKER_SCRIPT}")
target_compile_options(${KEYBOARD}
PRIVATE
${MCU_FLAGS}
-specs=nano.specs
-Wall
-Werror
-ffunction-sections
-fdata-sections
-fno-strict-aliasing
-fno-builtin
-fshort-enums
-fms-extensions
)
target_link_options(${KEYBOARD}
PRIVATE
${MCU_FLAGS}
-L${LINKER_PATH}
-T${LINKER_SCRIPT}
-specs=nano.specs
-specs=nosys.specs
-lc
-lm
-lnosys
-Wl,-Map=${KEYBOARD}.map,--cref
-Wl,--gc-sections
-Wl,--print-memory-usage
)
add_custom_command(TARGET ${KEYBOARD} POST_BUILD COMMAND ${OBJCOPY} -O ihex ${KEYBOARD}.elf ${KEYBOARD}.hex)
add_custom_command(TARGET ${KEYBOARD} POST_BUILD COMMAND ${OBJCOPY} -O binary ${KEYBOARD}.elf ${KEYBOARD}.bin)
add_custom_command(TARGET ${KEYBOARD} POST_BUILD COMMAND ${SIZE} ${KEYBOARD}.elf)