-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharm-gcc-utils.cmake
45 lines (40 loc) · 1.55 KB
/
arm-gcc-utils.cmake
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
# Get all subdirectories under ${current_dir} and store them
# in ${result} variable
macro(subdirlist result current_dir)
file(GLOB children ${current_dir}/*)
set(dirlist "")
foreach(child ${children})
if (IS_DIRECTORY ${child})
list(APPEND dirlist ${child})
endif()
endforeach()
set(${result} ${dirlist})
endmacro()
# Prepend ${CMAKE_CURRENT_SOURCE_DIR} to a ${directory} name
# and save it in PARENT_SCOPE ${variable}
macro(prepend_cur_dir variable directory)
set(${variable} ${CMAKE_CURRENT_SOURCE_DIR}/${directory})
endmacro()
# Add custom command to print firmware size in Berkley format
function(firmware_size target)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_SIZE_UTIL} -B
"${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}"
)
endfunction()
# Add a command to generate firmare in a provided format
function(generate_object target suffix type)
add_custom_target(${target}${suffix} ALL
DEPENDS ${target}
COMMAND ${CMAKE_OBJCOPY} -O${type}
"${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}" "${CMAKE_CURRENT_BINARY_DIR}/${target}${suffix}"
)
endfunction()
# Add a command to generate firmare in a provided format
function(generate_object_s target suffix type)
add_custom_target(${target}${suffix} ALL
DEPENDS ${target}
COMMAND ${CMAKE_OBJCOPY} -O${type} -S
"${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}" "${CMAKE_CURRENT_BINARY_DIR}/${target}${suffix}"
)
endfunction()