-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
50 lines (41 loc) · 1.48 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
cmake_minimum_required(VERSION 3.5)
set(PROJECT_NAME W7500-surf5)
include(${CMAKE_SOURCE_DIR}/tools/arm-none-eabi-gcc.cmake)
project(${PROJECT_NAME} ASM C CXX)
# Compiler options
function(complie_link_option name)
target_compile_options(${name} PRIVATE
-mcpu=cortex-m0
-mthumb
-fdata-sections
-ffunction-sections
-Wall
-O2
-g3
)
# Linker options
target_link_options(${name} PRIVATE
-T${CMAKE_SOURCE_DIR}/Libraries/CMSIS/Device/WIZnet/W7500/Source/GCC/gcc_w7500x.ld
-mcpu=cortex-m0
-mthumb
-specs=nano.specs
-lc
-lm
-Wl,-Map=${name}.map,--cref
-Wl,--gc-sections
-Xlinker -print-memory-usage -Xlinker
)
endfunction()
function(create_binary_file PROJECT_NAME)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}> $<IF:$<BOOL:$<TARGET_PROPERTY:${PROJECT_NAME},OUTPUT_NAME>>,$<TARGET_PROPERTY:${PROJECT_NAME},OUTPUT_NAME>,$<TARGET_PROPERTY:${PROJECT_NAME},NAME>>.bin)
endfunction()
function(create_elf_file PROJECT_NAME)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}> $<TARGET_FILE_DIR:${PROJECT_NAME}>/${PROJECT_NAME}.elf
COMMENT "Copying to ELF file: ${PROJECT_NAME}.elf"
)
endfunction()
set(EXAMPLES_DIR ${CMAKE_SOURCE_DIR}/Projects/W7500x_StdPeriph_Examples)
add_subdirectory(${EXAMPLES_DIR})
add_subdirectory(Libraries)
add_subdirectory(src)