Skip to content

Commit 8704da8

Browse files
committed
Create Greentea CMake Macro
1 parent 785d19b commit 8704da8

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tools/cmake/mbed_greentea.cmake

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0# the macro
3+
4+
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.mbedbuild CACHE INTERNAL "")
5+
6+
include(${MBED_PATH}/tools/cmake/app.cmake)
7+
8+
macro(mbed_greentea_cmake_macro)
9+
set(options)
10+
set(singleValueArgs TEST_NAME)
11+
set(multipleValueArgs TEST_INCLUDE_DIRS TEST_SOURCES TEST_REQUIRED_LIBS)
12+
cmake_parse_arguments(MBED_GREENTEA "${options}" "${singleValueArgs}"
13+
"${multipleValueArgs}" ${ARGN} )
14+
15+
set(TEST_NAME ${MBED_GREENTEA_TEST_NAME})
16+
17+
add_subdirectory(${MBED_PATH} build)
18+
19+
add_executable(${TEST_NAME})
20+
21+
mbed_configure_app_target(${TEST_NAME})
22+
23+
mbed_set_mbed_target_linker_script(${TEST_NAME})
24+
25+
target_include_directories(${TEST_NAME}
26+
PRIVATE
27+
.
28+
${MBED_GREENTEA_TEST_INCLUDE_DIRS}
29+
)
30+
31+
target_sources(${TEST_NAME}
32+
PRIVATE
33+
main.cpp
34+
${MBED_GREENTEA_TEST_SOURCES}
35+
)
36+
37+
if(MBED_BAREMETAL_GREENTEA_TEST)
38+
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-baremetal mbed-greentea)
39+
else()
40+
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-os mbed-greentea)
41+
endif()
42+
43+
target_link_libraries(${TEST_NAME}
44+
PRIVATE
45+
${MBED_GREENTEA_TEST_REQUIRED_LIBS}
46+
)
47+
48+
mbed_set_post_build(${TEST_NAME})
49+
50+
option(VERBOSE_BUILD "Have a verbose build process")
51+
if(VERBOSE_BUILD)
52+
set(CMAKE_VERBOSE_MAKEFILE ON)
53+
endif()
54+
55+
endmacro()

0 commit comments

Comments
 (0)