-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
67 lines (59 loc) · 1.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
cmake_minimum_required(VERSION 3.20)
project(wch_demo VERSION 0.1.0 LANGUAGES C CXX ASM)
set(CMAKE_CXX_STANDARD 14)
add_subdirectory(src/cppreg build/cppreg)
add_executable(wch_demo
src/ch32v003/startup/startup_ch32v00x.c
src/main.cpp
)
target_include_directories(wch_demo PRIVATE
src/ch32v003/startup
)
target_compile_options(wch_demo PRIVATE
-march=rv32ec
-mabi=ilp32e
-msmall-data-limit=0
#-msave-restore
-Os
-fmessage-length=0
-fsigned-char
-ffunction-sections
-fdata-sections
-fno-common
-g3
-Wall
-fstack-usage
-flto
)
target_link_libraries(wch_demo cppreg)
target_link_options(wch_demo PRIVATE
-march=rv32ec
-mabi=ilp32e
-msmall-data-limit=0
#-msave-restore
-Os
-fmessage-length=0
-fsigned-char
-ffunction-sections
-fdata-sections
-fno-common
-g3
-Wall
-fstack-usage
--specs=nano.specs
--specs=nosys.specs
-Wl,--print-memory-usage
-T "${CMAKE_SOURCE_DIR}/src/ch32v003/Ld/Link.ld"
-Wl,--gc-sections
-Wl,-Map=wch_demo.map
-nostartfiles
-Xlinker
)
set_target_properties(wch_demo PROPERTIES
SUFFIX ".elf"
)
add_custom_command(TARGET wch_demo POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ARGS -O ihex "$<TARGET_FILE:wch_demo>" wch_demo.hex
COMMAND ${CMAKE_OBJCOPY} ARGS -O binary "$<TARGET_FILE:wch_demo>" wch_demo.bin
COMMAND ${CMAKE_OBJDUMP} ARGS -S "$<TARGET_FILE:wch_demo>" > wch_demo.lst
)