-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
143 lines (107 loc) · 3.54 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
140
141
142
143
# -----------------------------------------------------------------------------
#
# This file is part of the µOS++ distribution.
# (https://github.com/micro-os-plus/)
# Copyright (c) 2022 Liviu Ionescu. All rights reserved.
#
# Permission to use, copy, modify, and/or distribute this software
# for any purpose is hereby granted, under the terms of the MIT license.
#
# If a copy of the license was not distributed with this file, it can
# be obtained from https://opensource.org/licenses/MIT/.
#
# -----------------------------------------------------------------------------
message(VERBOSE "Processing 'tests/platform-qemu-cortex-m7f'...")
# -----------------------------------------------------------------------------
# set(xpack_create_listing true)
# set(xpack_create_hex true)
# -----------------------------------------------------------------------------
# Define the tests executables.
function(add_test_executable name)
add_executable(${name})
set_target_properties(${name}
PROPERTIES
OUTPUT_NAME "${name}"
)
# Include folders.
# `tests/platform-qemu-cortex-m7f/include` was added globally.
target_include_directories(${name} PRIVATE
"../include"
)
message(VERBOSE "A+ -I tests/include")
# Application sources.
target_sources(${name} PRIVATE
"../src/${name}.cpp"
)
message(VERBOSE "A+ tests/src/${name}.cpp")
target_compile_definitions(${name} PRIVATE
# None
)
target_compile_options(${name} PRIVATE
# None
)
target_link_options(${name} PRIVATE
-Wl,-Map,platform-bin/${name}-map.txt
# -v
)
target_link_libraries(${name} PRIVATE
# Tested library.
micro-os-plus::utils-lists
# Portable dependencies.
micro-os-plus::diag-trace
# Platform specific dependencies.
micro-os-plus::platform # bring device & architecture too
micro-os-plus::semihosting
micro-os-plus::startup
)
# TODO use add_custom_target()
# https://cmake.org/cmake/help/v3.20/command/add_custom_command.html
add_custom_command(TARGET ${name} POST_BUILD
COMMAND ${CMAKE_SIZE} --format=berkeley "$<TARGET_FILE:${name}>"
)
if(xpack_create_hex)
add_custom_command(TARGET ${name} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O ihex "$<TARGET_FILE:${name}>" "$<TARGET_FILE:${name}>.hex"
)
endif()
if(xpack_create_listing)
add_custom_command(TARGET ${name} POST_BUILD
COMMAND ${CMAKE_OBJDUMP} --source --all-headers --demangle --line-numbers --wide "$<TARGET_FILE:${name}>" > ${name}-list.txt
VERBATIM
)
endif()
message(VERBOSE "A> ${name}")
endfunction()
# -----------------------------------------------------------------------------
if(ENABLE_SAMPLE_TEST)
add_test_executable(sample-test)
add_test(
NAME "sample-test"
COMMAND qemu-system-arm${extension}
--machine mps2-an500
--cpu cortex-m7
--kernel sample-test.elf
--nographic
-d unimp,guest_errors
--semihosting-config enable=on,target=native,arg=sample-test,arg=one,arg=two
)
endif()
# -----------------------------------------------------------------------------
if(ENABLE_UNIT_TEST)
add_test_executable(unit-test)
target_link_libraries(unit-test PRIVATE
micro-os-plus::micro-test-plus
)
add_test(
NAME "unit-test"
COMMAND qemu-system-arm${extension}
--machine mps2-an500
--cpu cortex-m7
--kernel unit-test.elf
--nographic
-d unimp,guest_errors
--semihosting-config enable=on,target=native,arg=unit-test
# --semihosting-config arg=--verbose
)
endif()
# -----------------------------------------------------------------------------